Is it possible to write a generator expression at any point that varies the output based on a property coming from being linked to something?
Such that in the following
add_library(widgets ...)
add_library(mouse ...)
...
add_library(input ...)
target_link_library(input PUBLIC $<IF:$<LINKAGE_INCLUDES:mouse>,widgets>)
add_executable(app ...)
target_link_libraries(app PUBLIC input mouse)
automatically links ‘input’ against ‘widgets’ because ‘mouse’ is present?
And is it possible to write a condition based on a property that is being gained as above by inheritance (so I don’t know the target name, its the name of the thing that asked to link me against it)
if (NOT HEADLESS)
set_property(TARGET some_other_target NEEDS_WIDGETS ON)
endif ()
...
target_link_libraries(mouse PUBLIC $<IF:$<INHERITED_PROPERTY:NEEDS_WIDGETS>,widgets>)
such that mouse implies widgets but only when ‘some_other_target’ is in the link chain?
— Edit
Clarification: What I’m trying to achieve is a library that pulls in different dependencies based on later linkage context, e.g linking readline vs x11 based on whether the command-line-arguments parser is being linked to us; linking the appropriate scripting library depending on whether the executable we end up linked to has USE_PYTHON or USE_JAVASCRIPT.