Use CMake components when installing
Description
While modernising my CMake, I realised that dune-common dumps all the installation files into the same bucket. While this is practical because one does not have to think what to install and what not, it is much cleaner to split installation in different components. This way, the user has much more control over the objects that get installed on its system or package. Doing this is simple: Adding a COMPONENT
argument to every install
CMake call.
Proposal
My proposal would be to have 4 components:
Component | Description | Example |
---|---|---|
Runtime |
Final scripts or binaries product of the module | Executables from application modules |
Development |
Header files and build system mandatory to continue downstream development | Header files, cmake macros |
Library |
Objects needed for both Development and Runtime usage in downstream modules |
libraries for UGGrid or libdunecommon
|
Documentation |
Documentation files | man pages, Doxygen |
In CMake, objects not assigned to any component are set to Unspecified
(current behaviour). With the proposed setting, nothing should be in this bucket.
Usage
Assuming components are set, installation of files in a given component is as simple as:
# User doesn't want to develop, just to link a final application
cmake --install . --component Library
# User wants to develop a downstream module
cmake --install . --component Library --component Development
# User wants to use final binaries
cmake --install . --component Library --component Runtime
# User wants to use everything (current behaviour)
cmake --install .
Is this backwards compatible?
Yes! If no component is given on the command line (current usage), all components are installed. This means that the change is backwards compatible with any installation script out there.
What next?
Discussion... If there seems to be agreement/interest, I can push a MR.