build-cpp / cmkr

Modern build system based on CMake and TOML.
https://cmkr.build
MIT License
439 stars 27 forks source link

Allow specifying install component name #51

Closed cursey closed 2 years ago

cursey commented 2 years ago

Sometimes you want a component to install a target, as well as some files. For example:

[[install]]
targets = ["MHRISE"]
destination = "MHRISE"

[[install]]
destination = "MHRISE"
files = ["dependencies/openvr/bin/win64/openvr_api.dll"]

This creates two install components, one which inherits the name of the target (MHRISE) and one that doesn't belong to any install component.

This PR lets you specify a component for the install so that you can do something like:

[[install]]
targets = ["MHRISE"]
destination = "MHRISE"
component = "MHRISE" # optional since its the same as the first target name

[[install]]
destination = "MHRISE"
files = ["dependencies/openvr/bin/win64/openvr_api.dll"]
component = "MHRISE"

Which lets you install the specific component along with the required files via command line:

cmake --install <build folder> --component MHRISE --prefix install

I found this necessary since while cmkr doesn't complain about the following:

[[install]]
targets = ["MHRISE"]
destination = "MHRISE"
files = ["dependencies/openvr/bin/win64/openvr_api.dll"]

CMake complains with: [cmake] install TARGETS given target "FILES" which does not exist.

mrexodia commented 2 years ago

Awesome, thanks!