Ninja unnecessarily runs CMake just after it was run manually
-
Create minimum CMakeLists.txt:
echo 'cmake_minimum_required(VERSION 3.0)' > CMakeLists.txt
-
Configure the project first time:
mkdir build cd build cmake .. -G Ninja
-
Update CMakeLists.txt:
touch ../CMakeLists.txt
-
Run Ninja. It will correctly re-configure the project because the timestamp has been updated.
ninja
-
Update CMakeLists.txt again:
touch ../CMakeLists.txt
-
This time run CMake manually:
cmake .
-
Run Ninja. It will re-configure the project again despite of the fact it has just been configured.
ninja
On step 4 Ninja stores mtime of build.ninja into .ninja_log. Then on step 6 CMake rewrites build.ninja and updates its mtime, so it obviously becomes newer than CMakeLists.txt. However in step 7 Ninja uses mtime from .ninja_log and re-runs CMake again.
$ stat -c "%Y" build.ninja
1512459573
$ ninja -d explain
ninja explain: recorded mtime of build.ninja older than most recent input ../CMakeLists.txt (1512459485 vs 1512459571)
[0/1] Re-running CMake...