[Cmake-commits] [cmake-commits] king committed CMakeLists.txt NONE 1.1 unset.cc NONE 1.1

cmake-commits at cmake.org cmake-commits at cmake.org
Mon Aug 25 10:31:31 EDT 2008


Update of /cvsroot/CMake/CMake/Tests/Unset
In directory public:/mounts/ram/cvs-serv10261/Tests/Unset

Added Files:
	CMakeLists.txt unset.cc 
Log Message:
ENH: Add unset() command.

This introduces the unset() command to make it easy to unset CMake
variables, environment variables, and CMake cache variables.  Previously
it was not even possible to unset ENV or CACHE variables (as in
completely remove them).  Changes based on patch from Philip Lowman.
See issue #7507.


--- NEW FILE: unset.cc ---
int main()
{
  return 0;
}

--- NEW FILE: CMakeLists.txt ---
project(Unset)

# Local variable
set(x 42)
if(NOT x EQUAL 42)
  message(FATAL_ERROR "x!=42")
endif(NOT x EQUAL 42)

if(NOT DEFINED x)
  message(FATAL_ERROR "x should be defined!")
endif(NOT DEFINED x)

unset(x)
if(DEFINED x)
  message(FATAL_ERROR "x should be undefined now!")
endif(DEFINED x)

# Local variable test unset via set()
set(x 43)
if(NOT x EQUAL 43)
  message(FATAL_ERROR "x!=43")
endif(NOT x EQUAL 43)
set(x)
if(DEFINED x)
  message(FATAL_ERROR "x should be undefined now!")
endif(DEFINED x)

# Cache variable
set(BAR "test" CACHE STRING "documentation")
if(NOT DEFINED BAR)
  message(FATAL_ERROR "BAR not defined")
endif(NOT DEFINED BAR)

unset(BAR CACHE)
if(DEFINED BAR)
  message(FATAL_ERROR "BAR still defined")
endif(DEFINED BAR)


add_executable(Unset unset.cc)



More information about the Cmake-commits mailing list