MantisBT - CMake
View Issue Details
0014786CMakeCMakepublic2014-03-05 08:062016-06-10 14:31
Philipp Möller 
Kitware Robot 
normalminoralways
closedmoved 
LinuxArch Linux
CMake 2.8.12.2 
CMake 3.0 
0014786: Imported targets always require an IMPORTED_LOCATION
When creating an imported target "importtarget" and not setting the IMPORTED_LOCATION property, targets linking against the imported target will have a dependency on importtarget-NOTFOUND, making it impossible to build.

A common use case is to manually create imported targets from the result of a find_package call for easy reference to the dependency in various places in the build system. Some libraries (like core Boost, Eigen) don't have any libraries.
Use:

cmake_minimum_required(VERSION 2.8)
project(Foo)

add_executable(main main.cpp)

add_library(Header_only_lib IMPORTED)
set_target_properties(${lib} PROPERTIES
  INTERFACE_INCLUDE_DIRECTORIES "/usr/include/my_lib"
  )
target_link_libraries(main Header_only_lib)

cmake .
make main # boom
AFAIK this is going to be resolved with add_library(foo INTERFACE IMPORTED), but a work-around for earlier CMake versions would be much appreciated.
No tags attached.
Issue History
2014-03-05 08:06Philipp MöllerNew Issue
2014-03-05 11:40Brad KingNote Added: 0035303
2014-03-05 11:40Brad KingStatusnew => acknowledged
2014-03-05 11:40Brad KingResolutionopen => fixed
2014-03-05 11:40Brad KingFixed in Version => CMake 3.0
2014-03-05 11:40Brad KingTarget Version => CMake 3.0
2016-06-10 14:29Kitware RobotNote Added: 0042497
2016-06-10 14:29Kitware RobotStatusacknowledged => resolved
2016-06-10 14:29Kitware RobotFixed in VersionCMake 3.0 =>
2016-06-10 14:29Kitware RobotResolutionfixed => moved
2016-06-10 14:29Kitware RobotAssigned To => Kitware Robot
2016-06-10 14:31Kitware RobotStatusresolved => closed

Notes
(0035303)
Brad King   
2014-03-05 11:40   
Correct, the INTERFACE library type is introduced in CMake 3.0.0-rc1 which has now been released. I do not think there is a work-around for older versions. The requirement for IMPORTED_LOCATION was by-design for non-INTERFACE imported targets.
(0042497)
Kitware Robot   
2016-06-10 14:29   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.