I encounter strange behavior when running CMake (3.5.1) in tandem with
Ninja (1.10.0): CMake is constantly re-run until Ninja finally gives up with
the following message:
ninja: error: manifest 'build.ninja' still dirty after 100 tries
Here is the minimal CMakeLists.txt file to reproduce this behavior:
add_library(mylib main.cpp) # Variable containing a generator expression. set(mylib_LIBRARY $<TARGET_FILE_NAME:mylib>) # Substitue expression @VAR@ by contents of variables. configure_file(mylib-config.cmake.in mylib-config.cmake.tmp) # Create final output file, evaluating generator expression(s). file(GENERATE OUTPUT mylib-config.cmake INPUT mylib-config.cmake.tmp)
mylib-config.cmake.in is just a one-liner:
The reason seems to be that the temporary intermediate file
mylib-config.cmake.tmp appears in the implicit dependencies controlling
whether to re-run CMake. Ninja complains about that and re-runs CMake:
ninja explain: output mylib-config.cmake.tmp of phony edge with no inputs doesn't exist
This behavior also happens with newer versions of CMake (e.g. 3.15.3).
Is this a bug in Ninja? It does not appear in earlier versions (e.g. 1.5.3).
However the logic of Ninja seems to be right (i.e. the file does in fact not
Is there a more elegant solution for the original problem (i.e. configuring a
file containing generator expressions)?