# IMPORTED\_LOCATION not set for imported target

**URL:** <https://discourse.cmake.org/t/imported-location-not-set-for-imported-target/7587>\
**Category:** Code\
**Created:** [March 2, 2023, 10:53am UTC](https://discourse.cmake.org/t/imported-location-not-set-for-imported-target/7587 "2023-03-02T10:53:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Leon0402](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/l/ccd318/32.png) [@Leon0402](https://discourse.cmake.org/u/Leon0402)\
**Post date:** [March 2, 2023, 10:53am UTC](https://discourse.cmake.org/t/imported-location-not-set-for-imported-target/7587/1 "2023-03-02T10:53:57Z")

</div>

Hi,

I do get the following error `IMPORTED_LOCATION not set for imported target sub::sub` and don’t know exactly how to resolve it.

I set up a small sample repository, which uses ros2 though: [GitHub - Leon0402/Sample-Ros-Workspace-with-dependency-management: Show how to build up a ros workspace with multiple ros and non ros dependencie](https://github.com/Leon0402/Sample-Ros-Workspace-with-dependency-management)

I only get the error if I set the CMAKE\_BUILD\_Type to Debug or Release or something else for the sub repository here: [Sample-Ros-Workspace-with-dependency-management/CMakeLists.txt at main · Leon0402/Sample-Ros-Workspace-with-dependency-management · GitHub](https://github.com/Leon0402/Sample-Ros-Workspace-with-dependency-management/blob/main/src/main/CMakeLists.txt#L30)

From what I can see with the CMAKE\_BUILD\_TYPE set, there will be generated a `subTargets.cmake` file, which specified all the targets that get imported when using find\_package.

If I don’t set the CMAKE\_BUILD\_TYPE, one additional file is generated. It is called `subTargets-noconfig.cmake`. Which contains this:

```auto
# Import target "sub::sub" for configuration ""
set_property(TARGET sub::sub APPEND PROPERTY IMPORTED_CONFIGURATIONS NOCONFIG)
set_target_properties(sub::sub PROPERTIES
  IMPORTED_LOCATION_NOCONFIG "${_IMPORT_PREFIX}/lib/libsub.so"
  IMPORTED_SONAME_NOCONFIG "libsub.so"
  )

```

So this sets the IMPORTED\_LOCATION apparently.

So the question is: Why is this not working when I set CMAKE\_BUILD\_TYPE. I figured it should create a file `subTargets-debug.cmake` or `subTargets-release.cmake`, but this is not the case. Maybe someone can explain what is going on and how to properly do this. Thanks!
