Pass native build-tool flags after CMake's double dash
PitfallVerified 30 Sep 2026Holds anywhere
Pitfall. The symptom, what causes it, and the fix that was run and seen to work.
Symptom#
cmake --build <dir> -j 8 -k 0 fails before the native build tool handles keep-going behavior.
Cause#
CMake reads -k as its own option.
Fix#
Put native tool arguments after --. For a Ninja build, use cmake --build <dir> -j 8 -- -k 0. Check the selected native tool's syntax; this does not make -k 0 portable to every generator.
Evidence#
Observer inbox ff5b1f7fb6 reports the failing invocation and the corrected argument boundary during dftracer-utils work. It does not include the exact CMake diagnostic.
Also found by searching
- cmake --build build -j 8 -k 0 fails, cmake treats -k as unknown option instead of passing it to ninja
- I want ninja to keep going after errors but cmake --build rejects the -k flag
- how do I pass ninja or make flags through cmake --build to the underlying build tool
- make -k keep-going equivalent when building via cmake --build, where do native generator arguments go
- cmake --build build -j 8 -k 0 CMake Error: Unknown argument -k
- how do I pass -k 0 keep going to ninja through cmake --build
- cmake build command rejects my ninja flag, unknown option error before building
- forward make/ninja arguments from cmake --build, like -- -k 0 or VERBOSE=1