cmake --install Command Reference
Stage built artifacts into an install prefix for packaging.
cmake --install copies the built artifacts into an install tree according to the project install() rules. In CI it stages files for packaging or container images.
What it does
cmake --install DIR runs the install rules from a configured and built project, copying binaries, libraries, and headers into a prefix. It replaces calling make install directly and works across generators.
Common flags and usage
- --install DIR: the build directory to install from
- --prefix PATH: override the install prefix
- --config Release|Debug: config for multi-config generators
- --component NAME: install only a named component
- DESTDIR=PATH (env): stage under a sandbox root for packaging
Example
shell
- name: Stage install tree
run: |
cmake --build build --config Release
DESTDIR="$PWD/stage" cmake --install build --prefix /usrIn CI
Use DESTDIR plus --prefix to stage an install tree under a sandbox root that a packaging step (tar, deb, container COPY) can consume. Select --component to package subsets like runtime versus development files.
Key takeaways
- cmake --install applies the project install() rules across generators.
- DESTDIR plus --prefix stages a sandbox tree for packaging.
- --component installs a subset like runtime or dev files.
Related guides
cmake --build Command ReferenceReference for cmake --build in CI/CD: drive any generator (Make or Ninja) through one portable command, selec…
cmake Configure Command ReferenceReference for the cmake configure step in CI/CD: generate a build system out-of-source with -S/-B, pick a gen…
CMake Presets Command ReferenceReference for CMake presets in CI/CD: capture configure, build, and test settings in CMakePresets.json so loc…