summaryrefslogtreecommitdiff
path: root/Tests/Unset
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2008-08-25 10:31:29 -0400
committerBrad King <brad.king@kitware.com>2008-08-25 10:31:29 -0400
commit33e865c041d95e383ce7e843a1a785cda78d13b7 (patch)
tree1d4f8014232a0ce4f6446123f472de6dc0d52751 /Tests/Unset
parent04fc897536fea61b548f06c21efca55db755a7e2 (diff)
downloadcmake-33e865c041d95e383ce7e843a1a785cda78d13b7.tar.gz
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/Unset')
-rw-r--r--Tests/Unset/CMakeLists.txt40
-rw-r--r--Tests/Unset/unset.cc4
2 files changed, 44 insertions, 0 deletions
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;
+}