genex `$<TARGET_NAME_IF_EXISTS:...>` in `install(TARGETS ...)`
I have a project that consists of multiple smaller targets, some of which are only added/included conditionally.
I include these targets in the top level CMakeLists.txt
file and would love to have a single install
call for all the targets, without needing to manually track which targets are added not.
For that having the ability to list all targets in the install(TARGETS ...)
call and wrapping the conditional targets in a $<TARGET_NAME_IF_EXISTS:...>
would be very convenient.
Example:
add_subdirectory(lib)
if (LINUX)
add_subdirectory(lib_linux)
endif ()
install(
TARGETS
lib
$<TARGET_NAME_IF_EXISTS:lib_linux>
# Further options
...
)
(The other option I could see is somehow making a listed target not existing non-fatal, maybe by prefixing it with a ?
or something)