diff options
author | Brad King <brad.king@kitware.com> | 2018-07-09 14:25:24 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2018-07-09 14:25:33 (GMT) |
commit | c878e6f8cc89ae5864d3446bf237bf53f1ee6563 (patch) | |
tree | 24f50ccd26862762b4501b271f7545a70f0dbe0c /Tests | |
parent | 1b5b1dc5cc5d1fd92fafcece3b4ae8ad51fd5817 (diff) | |
parent | 2a5f5c0e316d415e1b8207348b34761d34f191ae (diff) | |
download | CMake-c878e6f8cc89ae5864d3446bf237bf53f1ee6563.zip CMake-c878e6f8cc89ae5864d3446bf237bf53f1ee6563.tar.gz CMake-c878e6f8cc89ae5864d3446bf237bf53f1ee6563.tar.bz2 |
Merge topic 'option-normal-variable'
2a5f5c0e31 option: respect existing normal variable
12e6f83319 Option: Add a test that verifies interaction with normal variables
5bb3d40a28 cmOption: Remove VTK 4.0 workarounds
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2155
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/RunCMake/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/option/CMP0077-NEW.cmake | 14 | ||||
-rw-r--r-- | Tests/RunCMake/option/CMP0077-OLD.cmake | 9 | ||||
-rw-r--r-- | Tests/RunCMake/option/CMP0077-WARN-stderr.txt | 7 | ||||
-rw-r--r-- | Tests/RunCMake/option/CMP0077-WARN.cmake | 5 | ||||
-rw-r--r-- | Tests/RunCMake/option/CMakeLists.txt | 3 | ||||
-rw-r--r-- | Tests/RunCMake/option/RunCMakeTest.cmake | 5 |
7 files changed, 44 insertions, 0 deletions
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index c211f99..97c3178 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -240,6 +240,7 @@ add_RunCMake_test(include_guard) add_RunCMake_test(list) add_RunCMake_test(math) add_RunCMake_test(message) +add_RunCMake_test(option) add_RunCMake_test(project -DCMake_TEST_RESOURCES=${CMake_TEST_RESOURCES}) add_RunCMake_test(return) add_RunCMake_test(separate_arguments) diff --git a/Tests/RunCMake/option/CMP0077-NEW.cmake b/Tests/RunCMake/option/CMP0077-NEW.cmake new file mode 100644 index 0000000..d4c518b --- /dev/null +++ b/Tests/RunCMake/option/CMP0077-NEW.cmake @@ -0,0 +1,14 @@ + +#Verify that option DOESN'T overwrite existing normal variable when the policy +#is set to NEW +cmake_policy(SET CMP0077 NEW) +set(OPT_LOCAL_VAR FALSE) +option(OPT_LOCAL_VAR "TEST_VAR" ON) +if(OPT_LOCAL_VAR) + message(FATAL_ERROR "option failed to overwrite existing normal variable") +endif() + +get_property(_exists_in_cache CACHE OPT_LOCAL_VAR PROPERTY VALUE SET) +if(_exists_in_cache) + message(FATAL_ERROR "value should not exist in cache as it was already a local variable") +endif() diff --git a/Tests/RunCMake/option/CMP0077-OLD.cmake b/Tests/RunCMake/option/CMP0077-OLD.cmake new file mode 100644 index 0000000..4c52d4b --- /dev/null +++ b/Tests/RunCMake/option/CMP0077-OLD.cmake @@ -0,0 +1,9 @@ + +#Verify that option overwrites existing normal variable when the policy +#is set to OLD +cmake_policy(SET CMP0077 OLD) +set(OPT_LOCAL_VAR FALSE) +option(OPT_LOCAL_VAR "TEST_VAR" ON) +if(NOT OPT_LOCAL_VAR) + message(FATAL_ERROR "option failed to overwrite existing normal variable") +endif() diff --git a/Tests/RunCMake/option/CMP0077-WARN-stderr.txt b/Tests/RunCMake/option/CMP0077-WARN-stderr.txt new file mode 100644 index 0000000..0d02ffb --- /dev/null +++ b/Tests/RunCMake/option/CMP0077-WARN-stderr.txt @@ -0,0 +1,7 @@ +CMake Warning \(dev\) at CMP0077-WARN.cmake:5 \(option\): + Policy CMP0077 is not set: option\(\) honors normal variables. Run "cmake + --help-policy CMP0077" for policy details. Use the cmake_policy command to + set the policy and suppress this warning. + + For compatibility with older versions of CMake, option is clearing the + normal variable 'OPT_LOCAL_VAR'. diff --git a/Tests/RunCMake/option/CMP0077-WARN.cmake b/Tests/RunCMake/option/CMP0077-WARN.cmake new file mode 100644 index 0000000..7f99456 --- /dev/null +++ b/Tests/RunCMake/option/CMP0077-WARN.cmake @@ -0,0 +1,5 @@ + +#Verify that option overwrites existing normal variable when the policy +#is set to OLD +set(OPT_LOCAL_VAR FALSE) +option(OPT_LOCAL_VAR "TEST_VAR" ON) diff --git a/Tests/RunCMake/option/CMakeLists.txt b/Tests/RunCMake/option/CMakeLists.txt new file mode 100644 index 0000000..11dc49a --- /dev/null +++ b/Tests/RunCMake/option/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.12) +project(${RunCMake_TEST} CXX) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/option/RunCMakeTest.cmake b/Tests/RunCMake/option/RunCMakeTest.cmake new file mode 100644 index 0000000..0501624 --- /dev/null +++ b/Tests/RunCMake/option/RunCMakeTest.cmake @@ -0,0 +1,5 @@ +include(RunCMake) + +run_cmake(CMP0077-OLD) +run_cmake(CMP0077-NEW) +run_cmake(CMP0077-WARN) |