[CMake] disabling the cache

Bill Hoffman bill.hoffman at kitware.com
Wed Oct 31 12:00:38 EDT 2007


Jesper Eskilson wrote:
> Bill Hoffman wrote:
> 
>> OK, so you want to disable the rerun of CMake, not the cache.  That 
>> can be done with the CMAKE_SUPPRESS_REGENERATION variable. (set it to 
>> TRUE).
> 
> Yes, I know how to use this variable.
> 
>> You should never have to "clear out the cache".
> 
> If I make a change in CMakeLists.txt which should cause a (cached) 
> variable to change its value, don't I have to delete the cache for the 
> new value to be calculated?
> 
> Say that I use FIND_PROGRAM() to locate a program. If the program has 
> moved, how can CMake know that the value in the cache has to be 
> recalculated?
> 
For this case, you could have something like this:

# if SOME_PROGRAM has a value but the program has been moved
# or removed from the system, then clear the cache entry
# so that find_program will try again.
if(SOME_PROGRAM AND NOT EXISTS ${SOME_PROGRAM})
   set(SOME_PROGRAM NOTFOUND CACHE FORCE "some program")
endif(SOME_PROGRAM AND NOT EXISTS ${SOME_PROGRAM})
find_program(SOME_PROGRAM myprog)

So, if you know that you are changing a cmakelist file in a way that 
requires something to be removed from the cache, just remove it, but be 
careful not to remove it all the time.



-Bill




More information about the CMake mailing list