Skip to content
Latchkey

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 /usr

In 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

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →