MantisBT - CMake
View Issue Details
0015299CMakeModulespublic2014-12-11 06:362016-06-10 14:31
Paweł Stankowski 
Kitware Robot 
normalmajoralways
closedmoved 
 
 
0015299: CMakeExpandImportedTargets does not support generator expression TARGET_PROPERTY w/o target specified
CMakeExpandImportedTarget expands target names to file paths including targets from IMPORTED_LINK_INTERFACE_LIBRARIES* properties of expanded targets.

However, IMPORTED_LINK_INTERFACE_LIBRARIES property may contain generator expression $<TARGET_PROPERTY:prop>. It should be converted to $<TARGET_PROPERTY:target,prop> expression. Otherwise following error will appear:

"$<TARGET_PROPERTY:prop> may only be used with targets. It may not be used
  with add_custom_command. Specify the target to read a property from using
  the $<TARGET_PROPERTY:tgt,prop> signature instead".

BTW: INTERFACE_LINK_LIBRARIES property should be preferred, IMPORTED_LINK_INTERFACE_LIBRARIES should not be used when the former is defined. Currently INTERFACE_LINK_LIBRARIES property is ignored.
This is easily reproducible on Windows with Qt libraries.

For example, Qt5 adds following generator expression in IMPORTED_LINK_INTERFACE_LIBRARIES of Qt targets:
$<$<AND:$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>,$<BOOL:$<TARGET_PROPERTY:WIN32_EXECUTABLE>>,$<NOT:$<BOOL:$<TARGET_PROPERTY:Qt5_NO_LINK_QTMAIN>>>,$<TARGET_POLICY:CMP0020>>:Qt5::WinMain>;C:/Qt5/5.3/msvc2013_opengl/bin/Qt5Networkd.dll;C:/Qt5/5.3/msvc2013_opengl/bin/Qt5Cored.dll;$<$<AND:$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>,$<BOOL:$<TARGET_PROPERTY:WIN32_EXECUTABLE>>,$<NOT:$<BOOL:$<TARGET_PROPERTY:Qt5_NO_LINK_QTMAIN>>>,$<TARGET_POLICY:CMP0020>>:Qt5::WinMain>

Qt4 does similar thing.
No tags attached.
Issue History
2014-12-11 06:36Paweł StankowskiNew Issue
2014-12-11 10:52Brad KingNote Added: 0037444
2014-12-12 06:48Paweł StankowskiNote Added: 0037445
2014-12-12 08:33Brad KingNote Added: 0037446
2016-06-10 14:29Kitware RobotNote Added: 0042687
2016-06-10 14:29Kitware RobotStatusnew => resolved
2016-06-10 14:29Kitware RobotResolutionopen => moved
2016-06-10 14:29Kitware RobotAssigned To => Kitware Robot
2016-06-10 14:31Kitware RobotStatusresolved => closed

Notes
(0037444)
Brad King   
2014-12-11 10:52   
This module has been superseded in CMake 3.x by the LINK_LIBRARIES option to try_compile which knows how to handle imported targets.
(0037445)
Paweł Stankowski   
2014-12-12 06:48   
Yeah, but this module is still useful for me for CPack automation.

My case is that I want to install my main executable together will all its dependencies, which are mainly Qt5 imported targets. At first I tried:
  install(TARGETS ${DEPENDENCIES} ...)
but this does not work for imported targets.

So I use CMakeExpandImportedTarget module to translate imported target names to file paths and then run:
  install(PROGRAMS ${CMakeExpandImportedTarget_OUTPUT} ...)
and it works nicely if only I delete INTERFACE_LINK_LIBRARIES from Qt targets.

Can you suggest any alternative for installing imported targets to pack them using CPack? If not, I would be glad if you undeprecate this module.
(0037446)
Brad King   
2014-12-12 08:33   
Re 0015299:0037445: The BundleUtilities module has code to find runtime dependencies for packaging.

Also since CMake 3.0 the install(FILES) and install(PROGRAMS) commands accept generator expressions in the list of files to be installed.
(0042687)
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.