diff options
author | Brad King <brad.king@kitware.com> | 2013-10-08 12:37:47 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2013-10-08 12:37:50 (GMT) |
commit | 261c248254faf2fc09d71f456f018b7f8bc9a7f1 (patch) | |
tree | a23655839e6c669b682f6fff74d78a8a17dfc821 /Tests/Unset | |
parent | 1d9af198a8ea4e9329839c2e1f101106d8bdf505 (diff) | |
download | CMake-261c248254faf2fc09d71f456f018b7f8bc9a7f1.zip CMake-261c248254faf2fc09d71f456f018b7f8bc9a7f1.tar.gz CMake-261c248254faf2fc09d71f456f018b7f8bc9a7f1.tar.bz2 |
unset: Add PARENT_SCOPE option
Add an unset() command option to remove a variable from the calling
scope, just like the set() command's PARENT_SCOPE option. Teach the
Unset test to cover such cases.
Diffstat (limited to 'Tests/Unset')
-rw-r--r-- | Tests/Unset/CMakeLists.txt | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/Tests/Unset/CMakeLists.txt b/Tests/Unset/CMakeLists.txt index 781da3f..07aa68e 100644 --- a/Tests/Unset/CMakeLists.txt +++ b/Tests/Unset/CMakeLists.txt @@ -51,5 +51,32 @@ if(DEFINED BAR) message(FATAL_ERROR "BAR still defined") endif() +# Test unset(... PARENT_SCOPE) +function(unset_zots) + if(NOT DEFINED ZOT1) + message(FATAL_ERROR "ZOT1 is not defined inside function") + endif() + if(NOT DEFINED ZOT2) + message(FATAL_ERROR "ZOT2 is not defined inside function") + endif() + unset(ZOT1) + unset(ZOT2 PARENT_SCOPE) + if(DEFINED ZOT1) + message(FATAL_ERROR "ZOT1 is defined inside function after unset") + endif() + if(NOT DEFINED ZOT2) + message(FATAL_ERROR + "ZOT2 is not defined inside function after unset(... PARENT_SCOPE)") + endif() +endfunction() +set(ZOT1 1) +set(ZOT2 2) +unset_zots() +if(NOT DEFINED ZOT1) + message(FATAL_ERROR "ZOT1 is not still defined after function") +endif() +if(DEFINED ZOT2) + message(FATAL_ERROR "ZOT2 is still defined after function unset PARENT_SCOPE") +endif() add_executable(Unset unset.c) |