# CMake not being executed on first time make/ninja execution

**URL:** https://discourse.cmake.org/t/cmake-not-being-executed-on-first-time-make-ninja-execution/4781
**Category:** Usage
**Tags:** os:linux
**Created:** [January 5, 2022, 8:17pm UTC](https://discourse.cmake.org/t/cmake-not-being-executed-on-first-time-make-ninja-execution/4781 "2022-01-05T20:17:52Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![DKLind](https://discourse.cmake.org/user_avatar/discourse.cmake.org/dklind/32/526_2.png) [@DKLind](https://discourse.cmake.org/u/DKLind)
#### Post date: [January 5, 2022, 8:17pm UTC](https://discourse.cmake.org/t/cmake-not-being-executed-on-first-time-make-ninja-execution/4781/1 "2022-01-05T20:17:52Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [January 5, 2022, 8:24pm UTC](https://discourse.cmake.org/t/cmake-not-being-executed-on-first-time-make-ninja-execution/4781/2 "2022-01-05T20:24:08Z")

</div>

> [@DKLind](#):
>
> Is the second automatic CMake execution normal?

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

> [@DKLind](#):
>
> - If it is normal what triggers it?
> - What would cause the second execution not to occur?

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:

```auto
… 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

```
