Skip to content
Latchkey

cmake --build Command Reference

Build a configured project through one generator-agnostic command.

cmake --build invokes the underlying generator (Make, Ninja, MSBuild) with one portable syntax, so the same CI command works across platforms.

What it does

cmake --build DIR runs the native build tool for the build system generated into DIR. It abstracts over Make, Ninja, and MSBuild so your pipeline does not hardcode a generator-specific command.

Common flags and usage

  • --build DIR: the build directory to build
  • --target NAME: build a specific target (default: all)
  • --config Release|Debug: select config for multi-config generators
  • --parallel N / -j N: parallel build jobs
  • -- <native args>: pass options straight to the underlying tool

Example

shell
- name: Build
  run: cmake --build build --config Release --parallel "$(nproc)"

In CI

Use cmake --build everywhere so the same command works whether the generator is Make or Ninja. Pass --parallel "$(nproc)" to use all cores, and --config for multi-config generators where the build type is chosen at build time.

Key takeaways

  • cmake --build is generator-agnostic; the same command drives Make or Ninja.
  • --parallel N (or -j N) controls build parallelism.
  • --config selects the build type for multi-config generators.

Related guides

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