summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorRobert Maynard <robert.maynard@kitware.com>2018-06-21 18:52:12 (GMT)
committerRobert Maynard <robert.maynard@kitware.com>2018-06-21 18:52:12 (GMT)
commit12e6f83319d089b3295b4211d0d4810575e8f7d5 (patch)
tree3b1b8c28e2820c648737db91d21929fa1fb9f945 /Tests
parent5bb3d40a289c44f350aa68f32e5ef0c1ad7f13b1 (diff)
downloadCMake-12e6f83319d089b3295b4211d0d4810575e8f7d5.zip
CMake-12e6f83319d089b3295b4211d0d4810575e8f7d5.tar.gz
CMake-12e6f83319d089b3295b4211d0d4810575e8f7d5.tar.bz2
Option: Add a test that verifies interaction with normal variables
Diffstat (limited to 'Tests')
-rw-r--r--Tests/CMakeOnly/CMakeLists.txt1
-rw-r--r--Tests/CMakeOnly/option/CMakeLists.txt16
2 files changed, 17 insertions, 0 deletions
diff --git a/Tests/CMakeOnly/CMakeLists.txt b/Tests/CMakeOnly/CMakeLists.txt
index 204d54c..8a3a83b 100644
--- a/Tests/CMakeOnly/CMakeLists.txt
+++ b/Tests/CMakeOnly/CMakeLists.txt
@@ -49,6 +49,7 @@ add_CMakeOnly_test(TargetScope)
add_CMakeOnly_test(find_library)
add_CMakeOnly_test(find_path)
+add_CMakeOnly_test(option)
add_test(CMakeOnly.ProjectInclude ${CMAKE_CMAKE_COMMAND}
-DTEST=ProjectInclude
diff --git a/Tests/CMakeOnly/option/CMakeLists.txt b/Tests/CMakeOnly/option/CMakeLists.txt
new file mode 100644
index 0000000..d040fb5
--- /dev/null
+++ b/Tests/CMakeOnly/option/CMakeLists.txt
@@ -0,0 +1,16 @@
+cmake_minimum_required (VERSION 2.8)
+project(OptionTest NONE)
+
+#Verify that normal variable take precedence over cache variables
+option(OPT_LOCAL_VAR1 "TEST_VAR" ON)
+set(OPT_LOCAL_VAR1 FALSE)
+if(OPT_LOCAL_VAR1)
+ message(FATAL_ERROR "local variable didn't take precedence over cache variable")
+endif()
+
+#Verify that option overwrites existing normal variable
+set(OPT_LOCAL_VAR2 FALSE)
+option(OPT_LOCAL_VAR2 "TEST_VAR" ON)
+if(NOT OPT_LOCAL_VAR2)
+ message(FATAL_ERROR "option failed to overwrite existing normal variable")
+endif()