I wasn't sure how to set the title for this.
I basically have a code base that I build with cmake
; now I would like to know if it's safe to invoke cmake
itself on the same cache more than 1 time.
For example in the dir /path
I'm building a cache with
cmake -DVAR=VALUE < more flags >
and then in a second step I invoke cmake
again in the same directory /path
with another set of flags
cmake -DANOTHER_VAR=ANOTHER_VALUE < more flags >
at this point there are some guarantees that what is inside /path
is the result of both commands ? It depends on how the CMakeLists
is written ?
My building system that I use over cmake
could be simplified a little thanks to this steps, that's why I'm asking.
Yes, it's OK to do this. Actually, when you change something in your CMakeLists.txt's and then run
make
in build folder, CMake invokescmake .
there to regenerate the cache.Beside that,
-DVAR=VALUE
is an intended way for setting vars in the generated cache, as well as-UVAR
.The only exception is changing vars like
CMAKE_C_COMPILER
orCMAKE_CXX_COMPILER
. If you alter them withcmake -DCMAKE_C_COMPILER=newcc .
, CMake would wipe your cache and generate it from scratch.