Proper way to set install rules once
Provided we have a project which contains (among other targets) a considerable amount of libraries with the same build and install setup, we can set the build rules once by
- Creating an interface target, e.g.
add_library(super INTERFACE)
, - Setting its properties, e.g. with
set_target_properties(super PROPERTIES INTERFACE_<property> <value>)
, - Linking each of targets against
super
, e.g.target_link_libraries(<target> PRIVATE super)
.
However, install rules could not be propagated in the same way, thus requiring user to (IMHO, from worst to near-best):
- either invoke the same
install()
function for each and every target, - or write a parameterised function, e.g.
install_target(<target>)
, and invoke it for every target, - or accumulate all targets in a list and call
install()
function on that list, - or override built-in target declaration function with, e.g.
add_installable_library()
overadd_library()
.
My point being, it would be much easier to accomplish this in target-based modern-cmake way by allowing interface targets to somehow propagate install rules. WDYT?
Edited by Arseny Aprelev