install(TARGETS): Proposal to simplify componentization
Since CMake 3.14, one can write an install(TARGETS)
to use cross-platform paths as destinations like so:
install(TARGETS project_library)
However, once the user wishes to componentize this, they must start a block and name the components for each one, making sure that they match up and are prefixed to allow vendoring code:
install(
TARGETS project_library
RUNTIME #
COMPONENT project_Runtime
LIBRARY #
COMPONENT project_Runtime
NAMELINK_COMPONENT project_Development
ARCHIVE #
COMPONENT project_Development
)
I believe that in the interest of keeping things simple and adopting commonalities, this could be further simplified using a COMPONENT_PREFIX
argument:
install(TARGETS project_library COMPONENT_PREFIX project_)
The semantics of this would be as-if the user wrote this:
install(
TARGETS project_library
RUNTIME #
COMPONENT project_Runtime
LIBRARY #
COMPONENT project_Runtime
NAMELINK_COMPONENT project_Development
ARCHIVE #
COMPONENT project_Development
OBJECTS #
COMPONENT project_Development
BUNDLE #
COMPONENT project_Runtime
FRAMEWORK #
COMPONENT project_Runtime
PUBLIC_HEADER #
COMPONENT project_Development
PRIVATE_HEADER #
COMPONENT project_Development
RESOURCE #
COMPONENT project_Runtime
)
This could be overwritten in a piecemeal fashion by starting a block and defining the component there:
install(
TARGETS project_library
COMPONENT_PREFIX project_
RESOURCE #
COMPONENT Resources
)
I believe that the names here encompass a common enough idiom that this should be made part of this command.
Edited by friendlyanon