[CMake] losing CMakeCache.txt after changing the compiler...

René J.V. Bertin rjvbertin at gmail.com
Sat Jun 2 05:43:02 EDT 2018


Hi,

This happened once too often for me: I apply successive tweaks to a CMakeCache file, reinvoke make (or ninja) and then at some point lose everything because I forgot that changing the compiler is a "lethal" operation.

Why does cmake have to throw away the entire cache file when something changes in the compiler path? That seems like a cheap way to implement a "let's keep track of which cached settings depend on the choice of compiler". At the least it wouldn't be much less cheap to rename CMakeCache.txt to CMakeCache.bak instead of deleting it.

And FWIW, this is also a situation in which storing the exact CMake invocation in a comment at the top of the cache file could be useful...

R.


More information about the CMake mailing list