diff options
author | Brad King <brad.king@kitware.com> | 2008-08-25 14:31:29 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2008-08-25 14:31:29 (GMT) |
commit | 33e865c041d95e383ce7e843a1a785cda78d13b7 (patch) | |
tree | 1d4f8014232a0ce4f6446123f472de6dc0d52751 /Tests | |
parent | 04fc897536fea61b548f06c21efca55db755a7e2 (diff) | |
download | CMake-33e865c041d95e383ce7e843a1a785cda78d13b7.zip CMake-33e865c041d95e383ce7e843a1a785cda78d13b7.tar.gz CMake-33e865c041d95e383ce7e843a1a785cda78d13b7.tar.bz2 |
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.
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Tests/Unset/CMakeLists.txt | 40 | ||||
-rw-r--r-- | Tests/Unset/unset.cc | 4 |
3 files changed, 45 insertions, 0 deletions
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index ce0cd42..14366b3 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -94,6 +94,7 @@ IF(BUILD_TESTING) ADD_TEST_MACRO(SourceGroups SourceGroups) ADD_TEST_MACRO(Preprocess Preprocess) ADD_TEST_MACRO(ExportImport ExportImport) + ADD_TEST_MACRO(Unset Unset) # If we are running right now with a UnixMakefiles based generator, diff --git a/Tests/Unset/CMakeLists.txt b/Tests/Unset/CMakeLists.txt new file mode 100644 index 0000000..6260950 --- /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 0000000..f8b643a --- /dev/null +++ b/Tests/Unset/unset.cc @@ -0,0 +1,4 @@ +int main() +{ + return 0; +} |