From 33e865c041d95e383ce7e843a1a785cda78d13b7 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 25 Aug 2008 10:31:29 -0400 Subject: 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. --- Tests/Unset/CMakeLists.txt | 40 ++++++++++++++++++++++++++++++++++++++++ Tests/Unset/unset.cc | 4 ++++ 2 files changed, 44 insertions(+) create mode 100644 Tests/Unset/CMakeLists.txt create mode 100644 Tests/Unset/unset.cc (limited to 'Tests/Unset') diff --git a/Tests/Unset/CMakeLists.txt b/Tests/Unset/CMakeLists.txt new file mode 100644 index 0000000000..626095054e --- /dev/null +++ b/Tests/Unset/CMakeLists.txt @@ -0,0 +1,40 @@ +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) diff --git a/Tests/Unset/unset.cc b/Tests/Unset/unset.cc new file mode 100644 index 0000000000..f8b643afbf --- /dev/null +++ b/Tests/Unset/unset.cc @@ -0,0 +1,4 @@ +int main() +{ + return 0; +} -- cgit v1.2.1