CMake/Tests/CMakeCommands/target_link_libraries
Stephen Kelly 77d2646784 Allow generator expressions in LINK_INTERFACE_LIBRARIES.
The Config and IMPORTED_ variants may also contain generator
expressions.

If 'the implementation is the interface', then the result of
evaluating the expressions at generate time is used to populate
the IMPORTED_LINK_INTERFACE_LIBRARIES property.

1) In the case of non-static libraries, this is fine because the
  user still has the option to populate the LINK_INTERFACE_LIBRARIES
  with generator expressions if that is what is wanted.

2) In the case of static libraries, this prevents a footgun,
  enforcing that the interface and the implementation are really
  the same.

  Otherwise, the LINK_LIBRARIES could contain a generator
  expression which is evaluated with a different context at build
  time, and when used as an imported target. That would mean that the
  result of evaluating the INTERFACE_LINK_LIBRARIES property for
  a static library would not necessarily be the 'link implementation'.

  For example:

    add_library(libone STATIC libone.cpp)
    add_library(libtwo STATIC libtwo.cpp)
    add_library(libthree STATIC libthree.cpp)

    target_link_libraries(libtwo
      $<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,STATIC_LIBRARY>:libone>)
    target_link_libraries(libthree libtwo)

  If the LINK_LIBRARIES content was simply copied to the
  IMPORTED_LINK_INTERFACE_LIBRARIES, then libthree links to libone, but
  executables linking to libthree will not link to libone.

3) As the 'implementation is the interface' concept is to be
  deprecated in the future anyway, this should be fine.
2013-01-10 23:04:06 +01:00
..
subdir Add CMAKE_BUILD_INTERFACE_INCLUDES build-variable. 2013-01-08 14:14:27 -05:00
CMakeLists.txt Allow generator expressions in LINK_INTERFACE_LIBRARIES. 2013-01-10 23:04:06 +01:00
depA.cpp target_link_libraries: Add LINK_(PUBLIC|PRIVATE) options 2011-11-22 16:52:35 -05:00
depA.h target_link_libraries: Add LINK_(PUBLIC|PRIVATE) options 2011-11-22 16:52:35 -05:00
depB.cpp Add LINK_LIBRARIES property for direct target link dependencies 2013-01-08 09:02:43 -05:00
depB.h target_link_libraries: Add LINK_(PUBLIC|PRIVATE) options 2011-11-22 16:52:35 -05:00
depC.cpp GenerateExportHeader test: add newlines before end of file 2012-01-18 00:01:08 +01:00
depC.h target_link_libraries: Add LINK_(PUBLIC|PRIVATE) options 2011-11-22 16:52:35 -05:00
depD.cpp Allow generator expressions in LINK_INTERFACE_LIBRARIES. 2013-01-10 23:04:06 +01:00
depD.h Allow generator expressions in LINK_INTERFACE_LIBRARIES. 2013-01-10 23:04:06 +01:00
depIfaceOnly.cpp Make targets depend on the link interface of their dependees. 2013-01-03 13:31:50 -05:00
depIfaceOnly.h Make targets depend on the link interface of their dependees. 2013-01-03 13:31:50 -05:00
libgenex.cpp Add LINK_LIBRARIES property for direct target link dependencies 2013-01-08 09:02:43 -05:00
libgenex.h Add LINK_LIBRARIES property for direct target link dependencies 2013-01-08 09:02:43 -05:00
targetA.cpp Add CMAKE_BUILD_INTERFACE_INCLUDES build-variable. 2013-01-08 14:14:27 -05:00
targetB.cpp Allow generator expressions in LINK_INTERFACE_LIBRARIES. 2013-01-10 23:04:06 +01:00