[Cmake] Ad: Strange behavior of FIND_PROGRAM

Brad King brad.king at kitware.com
Wed, 03 Mar 2004 13:08:17 -0500


David Svoboda wrote:

> To explain the problem better:
> 
> If you set some cache variable, say MY_PROGRAM to the value
> C:\bin\beep.exe, by hand in GUI and then you use SET(MY_PROGRAM "NOTFOUND"
> CACHE FILEPATH "" FORCE), be sure, that this value is stored in
> CMakeCache.txt and somewhere else!!?
> 
> Now, if you run CMake command
> 
> FIND_PROGRAM(MY_PROGRAM	NAMES myprog)
> 
> without advising any paths, the Windows CMake finds the previous value,
> i.e C:\bin\beep.exe. You can set some paths in FIND_PROGRAM command, but
> it does not matter - CMake does not take care about it - the previous
> value, that is stored somewhere in the memory, is prime.
> 
> 
> The only solution I found is to exit CMake (memory is flushed) and run it
> again :-(

The FIND_PROGRAM command's first argument names a CMake cache entry.  If 
the entry is already set to something other than NOTFOUND, it does 
nothing.  The cache is stored in CMakeCache.txt at the top of the build 
tree between runs of CMake.  It is stored in memory while CMake is 
running.  The value in the cache is always preferred because it is 
assumed that the user has seen the value in the GUI and accepted it.  If 
you want to run the search again, remove the entry from the cache (using 
the delete option in the GUI).  The next time the configure phase runs, 
the search will run again.

-Brad