[CMake] Removing unused variables from the cache

Brad King brad.king at kitware.com
Thu Oct 19 10:42:30 EDT 2006


Sylvain Benner wrote:
> I don't know if this is possible but you can set your variable to an
> empty string.
> 
> SET( SOME_OPTION "")
> 
>> Is it possible to remove variables from the cache ? For example:
>>
>> OPTION( BUILD_X "Descr" OFF )
>>
>> IF ( BUILD_X )
>>    SET( SOME_OPTION "Hello world" CACHE)
>> ELSEIF (BUILD_X)
>>    UNSET( SOME_OPTION )
>> ENDIF ( BUILD_X )

If BUILD_X is on and SOME_OPTION is set by the user, then BUILD_X is
turned off, and then back on the user may expect SOME_OPTION to have
retained its value.  You can convert it to an INTERNAL cache entry so
that it does not show up in the GUI when it is not needed and then use
FORCE to change its type back later.  Here is an example macro to do
that for on/off sub-options:

http://www.vtk.org/cgi-bin/viewcvs.cgi/CMake/vtkDependentOption.cmake?rev=1.5&view=markup

-Brad


More information about the CMake mailing list