ninja Command: Fast Builds in CI
ninja executes build graphs quickly, focused on speed over hand-authoring.
Ninja is a minimal, very fast build system meant to be generated by tools like CMake or Meson rather than written by hand. In CI it executes the build.ninja graph with high parallelism, which is why CMake + Ninja is a common fast-build combination.
Common flags
-j N- run N jobs in parallel (defaults to detected core count)-C DIR- change to DIR before building-f FILE- use a build file other than build.ninja-k N- keep going until N jobs fail (0 = unlimited)-v- verbose: print full command lines-t targets/-t clean- run a Ninja tool (list targets, clean)-n- dry run; do not execute commands
Example in CI
Build a CMake-generated Ninja graph verbosely with bounded parallelism:
shell
ninja -C build -j$(nproc) -vCommon errors in CI
- ninja: error: loading 'build.ninja': No such file or directory - not configured yet
- ninja: error: unknown target 'X' - target not in the build graph
- ninja: build stopped: subcommand failed - a compile/link step failed
- ninja: error: manifest 'build.ninja' still dirty after 100 tries - regen loop
Key takeaways
- Ninja files are generated (by CMake/Meson), not authored by hand.
- "No such file" for build.ninja means you skipped the configure step.
- Pair
cmake -G Ninjawithninjafor the fastest CI C/C++ builds.
Related guides
cmake Command: Configure C++ Builds in CIcmake configures and builds C/C++ projects. Reference for -S, -B, -G, -D, --build, --target, --preset, and th…
make Command: Run Builds in CImake runs builds from a Makefile. Reference for -j, -C, -f, -B, -k, VAR=value overrides, and the Makefile err…
bazel Command: Build Monorepos in CIbazel is a hermetic, cached build system. Reference for build, test, //..., --config, --remote_cache, --keep_…