Compatible Interface target property is not visible in target_link_libraries generator expressions
Hi, I would like to select one out of two implementations of a library, using "compatible interface" properties.
However, when I define a "compatible interface" property, as shown below, it is empty when resolving generator expressions in target_link_libraries.
It does work properly:
- with target_link_options and target_compile_definitions
- when a regular target property is used
See below, -DLOexe1 is set to 1 (link option). -DLLexe1 is set to nothing (same generator expression, with target_link libraries)
/usr/bin/cc -DLOexe1=1 CMakeFiles/exe1.dir/main.c.o -o exe1 libfoo.a liblib_impl2.a -DLLexe1=
set_property(TARGET lib_interface APPEND PROPERTY
COMPATIBLE_INTERFACE_NUMBER_MAX NEED_IMPL1
)
set_property(TARGET lib_interface PROPERTY INTERFACE_NEED_IMPL1 0)
# yields -DLL= on linker cmdline (so without any value of NEED_IMPL1 target property)
target_link_libraries(lib_interface INTERFACE -DLL$<TARGET_PROPERTY:NAME>=$<TARGET_PROPERTY:NEED_IMPL1>)
# yields -DLO=1 on linker cmdline (so with correct value of NEED_IMPL1 target property)
target_link_options(lib_interface INTERFACE -DLO$<TARGET_PROPERTY:NAME>=$<TARGET_PROPERTY:NEED_IMPL1> )
# yields -DCD=1 on compiler cmdline (so with correct value of NEED_IMPL1 target property)
target_compile_definitions(lib_interface INTERFACE CD$<TARGET_PROPERTY:NAME>=$<TARGET_PROPERTY:NEED_IMPL1> )