[CMake] CMake and Ninja, RERUN_CMAKE useless?

Nagurne, James j-nagurne at ti.com
Tue Oct 8 18:57:37 EDT 2019


Hi all,

My question comes from a Ninja generator build system, and is specifically about an internal rule generated by cmake.
What is the purpose of the RERUN_CMAKE rule generated by CMake with a Ninja generator?

In the current repo, the only reference to this rule is in WriteTargetRebuildManifest here<https://github.com/Kitware/CMake/blob/a1f78a481c8cbda1f0c8503c4d661c3c3ddf00a6/Source/cmGlobalNinjaGenerator.cxx#L1266>
At line 1285, the rule is written out, seemingly as-is.

According to lines 1274 to 1284, the only actual behavior of this command, which is executed whenever the source CMakeLists.txt file, files included from the CMakeLists, and some other CMake installation files change, is:
cmake -S <source_dir> -B <binary_dir>

This seems completely insufficient for "re-running" cmake. The most obvious flaw is the absence of the generator. When I've seen this rule fire, my Ninja build system adds a useless Makefile to the build system, and then (hopefully) continues building as if nothing had been done at all, without so much as inspecting that Makefile.

What about command-line arguments like -D?

Am I missing the purpose of this rule or potentially doing something non-standard? The reason I send an email is because this behavior is sending my project into a cmake loop where it detects build.ninja is out of date, re-runs cmake to generate a Makefile instead of a ninja build system, and then infinitely repeats because it never actually re-ran anything.

Thanks,
JB
Code Generation
Texas Instruments
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20191008/12bfe634/attachment.html>


More information about the CMake mailing list