From 12e6f83319d089b3295b4211d0d4810575e8f7d5 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Thu, 21 Jun 2018 14:52:12 -0400 Subject: Option: Add a test that verifies interaction with normal variables --- Tests/CMakeOnly/CMakeLists.txt | 1 + Tests/CMakeOnly/option/CMakeLists.txt | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 Tests/CMakeOnly/option/CMakeLists.txt 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() -- cgit v0.12