[CMake] Deleting a variable

James Bigler bigler at cs.utah.edu
Mon Dec 4 19:04:37 EST 2006


Alexander Neundorf wrote:
> Hi,
> 
> 
> Von: James Bigler <bigler at cs.utah.edu>
> 
>> I have some optional code that runs and creates some variables
>>
>> IF(MY_VAR)
>>    SET(MY_OTHER_VAR 2)
>> ENDIF(MY_VAR)
>>
>> If I turn off MY_VAR, I want MY_OTHER_VAR to do away like this:
>>
>> IF(MY_VAR)
>>    SET(MY_OTHER_VAR 2)
>> ELSE(MY_VAR)
>>    DELETE(MY_OTHER_VAR)
>> ENDIF(MY_VAR)
> 
> SET(MY_OTHER_VAR)
> or
> SET(MY_OTHER_VAR FALSE)
> should have the same effect, at least both will evaluate to false.
> Is this good enough or do you need more ?

I want the variable to disappear from the list when running ccmake. 
This didn't seem to do anything.

BTW, This is a more complete example:

FIND_PROGRAM(MY_EXECUTABLE
   NAMES myproggy
   PATHS )

IF(EXISTS ${MY_EXECUTABLE})
   SET(FOUND_MY_PROGGY 1)
ELSE(EXISTS ${MY_EXECUTABLE})
   SET(FOUND_MY_PROGGY 0)
   # I want to remove MY_PROGGY from the ccmake display list
   SET(MY_EXECUTABLE)
ENDIF(EXISTS ${MY_EXECUTABLE})

# You need at least version 2.4 for this to work.
IF("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.4)
   MESSAGE("You need at least version 2.4 for generating output.  Go get 
it from http://www.cmake.org/HTML/Download.html")
   SET(FOUND_MY_PROGGY 0)
   # I really want to delete references to MY_EXECUTABLE
   SET(MY_EXECUTABLE "")
ENDIF("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.4)


Thanks,
James


More information about the CMake mailing list