Is there an equivalent of make -k
for CMake, with other words, so that CMake keeps going compiling the other files even if an error occurs in one file?
Asked
Active
Viewed 457 times
2

usr1234567
- 21,601
- 16
- 108
- 128

David Casper
- 394
- 2
- 9
-
Which exact **kind of error** do you want to skip? It is not CMake who *compiles* files and does other **build** steps. CMake performs only **configuration**. The errors during configuration are already classified as **fatal**, which immediately terminates configuration (e.g. because following steps have no sense after the error) and **non-fatal**, which allow configuration to continue until the end. So for CMake itself `-k` option would have a little sense. – Tsyvarev Nov 01 '21 at 07:06
-
just generate `makefiles` by cmake and use `make -k` when building. You are probably generating `ninja` or something else... but cmake can also generate `makefiles`. – igagis Nov 01 '21 at 14:39
-
Thanks for the education, I am using QtCreator and thought cmake was an alternative to qmake. In that environment I can configure a make -k on the qmake output. Now the compilations must be made by ninja or whatever. But I see now this is really a qtcreator question and not a cmake question. My mistake. So i will post this on the qtcreator forum rather than here on stackoverflow. Again thanks for educating me. – David Casper Nov 02 '21 at 05:52
-
If you are using Ninja, you have to provide an additional argument of how many errors are allowed to occur before Ninja stops with `0` being infinite. `ninja -k 0` would be the equivalent of `make -k`. See also https://stackoverflow.com/q/58920832/2799037. – usr1234567 Dec 26 '21 at 07:32
2 Answers
4
CMake does not steer the compiling itself, it delegates it to some build toolset like Make, Ninja, msbuild etc. If the tool is called, you have to add the arguments to the call, for example, add -k
to your make call and -k 0
to your Ninja call.
If you build via the CMake command cmake -build <options>
, you can add the build-toolset specific argument after a --
like in
cmake -build <options> -- -k
for make.

usr1234567
- 21,601
- 16
- 108
- 128
0
So usr1234567's answer is what I was looking for. In using it for QtCreator, the place to set this is in a collapsed dialog box, so it is not immediately obvious. You go to 'build settings', then press 'details' and can insert the -k 0 on the tool settings line.

David Casper
- 394
- 2
- 9