IMPORTED_LOCATION not set for imported target


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

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

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:

# Import target "sub::sub" for configuration ""
set_target_properties(sub::sub PROPERTIES

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!