CMake not being executed on first time make/ninja execution

One thing I’ve taken for granted with using CMake is this. After cleaning a build directory and CMake is executed manually the first time, when make/ninja are executed, CMake is executed again automatically. This used to be the case for me. Now all of the sudden the second CMake execution isn’t happening. Admittedly, I have no idea why CMake was being executed twice, as I said, I’ve just taken it for granted that it does.

The issue is this: I have a large project where some CMakeLists.txt scripts are referencing CPACK version variables. But, there is a “chicken and egg” issue on a couple of sub-projects that require the second CMake execution in order for some CPACK variables to be set.

I know when CMakeLists.txt files are changed in a project and, in a incremental build, CMake is automatically executed with make/ninja execution.

Three questions:

  1. Is the second automatic CMake execution normal?
  2. If it is normal what triggers it?
  3. What would cause the second execution not to occur?

No, I don’t think I’ve seen this as some “default” behavior.

I would ask ninja with -d explain to see why it thinks it needs to rerun cmake. Looking at a fresh configure of cmake itself, the first thing done is a build:

… logs of `ninja explain:` logs
ninja explain: Auxiliary/all is dirty
[1052-14->1/1066@15.1] Building CXX object Source/kwsys/CMakeFiles/cmsysTestsCxx.dir/testConfigure.cxx.o