Generation expression based on dependee?

This is what I call “intersectional usage requirements” (or “I use A and B therefore C” kind of logic). CMake doesn’t have support for this. What you can do is something like:

target_link_libraries(input
  INTERFACE
    "$<$<BOOL:$<TARGET_PROPERTY:USES_MOUSE>>:widgets>")

add_executable(app)
target_link_libraries(app PUBLIC input mouse)
set_property(TARGET app PROPERTY USES_MOUSE 1)

There’s also no support for $<INHERITED_PROPERTY> because it can cause undecidable builds (a “later” target could “set” a property that changes what an “earlier” target would have done which, if followed, makes the “later” target not necessary: basically a way to say “this sentence is false”).

1 Like