Add only library headers during target_link_libraries()

I wholeheartedly second the request for such a feature. We have a large suite of runtime-loaded libraries in a project. They have usage requirements (all have include directories, sometime have compile definitions too) which we’d love to propagate using CMake’s transitive usage requirement mechanism, but without linking the library itself.

I am aware there’s this possible workaround:

# instead of target_link_libraries(Consumer PRIVATE Library), do
target_include_directories(Consumer PRIVATE $<TARGET_PROPERTY:Library,INTERFACE_INCLUDE_DIRECTORIES>)

However, that needs one such line for each INTERFACE_* property potentially set on the Library target. It could be wrapped in a project-side function to set all such properties, but that then needs maintenance whenever CMake adds a new INTERFACE_* property, and still feels like unnecessary duplication of functionality CMake must have internally anyway.