[CMake] CMake doesn't preserve command line overrides on restart
Paul Smith
paul at mad-scientist.net
Tue Dec 22 14:57:55 EST 2015
If my compiler changes between the last invocation of cmake and this
one, then cmake will restart itself; this part works fine. The problem
is that if I've invoked cmake with some command line overrides, they are
lost when I restart. For example if I have in my makefile:
set(BUILDNUM "0" CACHE STRING "Build Number")
message(STATUS "Build number = ${BUILDNUM}")
by default this is 0, so when developers build locally the build number
is 0. When cmake is invoked through our CI build system, it is run like
this:
cmake -DBUILDNUM=125 .
or whatever the current build number is for that build.
However, if the compiler has changed and we need to restart the build,
this breaks:
-- Build number = 125
-- Configuring done
You have changed variables that require your cache to be deleted.
Configure will be re-run and you may have to reset some variables.
The following variables have changed:
CMAKE_C_COMPILER= /new/bin/x86_64-rh55-linux-gnu-gcc
CMAKE_CXX_COMPILER= /new/bin/x86_64-rh55-linux-gnu-g++
-- Build number = 0
-- Configuring done
-- Generating done
-- Build
files have been written to: /home/psmith/src/cmake/restart
Note that when cmake re-runs itself the command line setting for BUILDNUM has been lost and it reverts to the default value.
To me this is a bug... thoughts?
More information about the CMake
mailing list