Install everything _but_certain components

I work on packaging for conda-forge, and we often want to separate multiple outputs for one project (commonly separating a shared library and language bindings, but could be any reason to subset files into outputs).

This often amounts to running build once, then install specific components in multiple stages to easily track different subsets of files. However, one thing I haven’t figured out how to do easily: install everything except specified component(s).

Basically, I want the pattern:

cmake --install build --exclude-component some-component # artifact 1
cmake --install build --component some-component # artifact 2

but I haven’t been able to produce artifact 1 without patching the CMakeLists to add EXCLUDE_FROM_ALL to all the components I want to select separately. Is there a way to do this without patching upstream CMakeLists?

If I assume everything is in a component (not a safe assumption, I think), I could always do --component installs, but I don’t see a way to discover what all the components are to produce the initial list. Does that command exist?

this package is an example of splitting a cmake build into components, where patching in EXCLUDE_FROM_ALL is used to get it to do what I want.

Components are kind of ad hoc and not centrally managed by CMake, so without that, knowing what kind of set we’re subtracting from is problematic. Of course, there could also be a CMAKE_INSTALL_COMPONENT_EXCLUDE variable that, if set and matches, then skips whatever it guards.

Thanks! Consider this a feature request for that --exclude-component variable, then.

Concrete feature requests are tracked in the issue tracker.

It would also be nice to be able to install everything in one command, even what is EXCLUDE_FROM_ALL. I’ll open a issue.

https://gitlab.kitware.com/cmake/cmake/-/issues/24335