mirror of
https://github.com/Kitware/CMake.git
synced 2026-07-02 20:57:29 +00:00
Option: Add a test that verifies interaction with normal variables
This commit is contained in:
@@ -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
|
||||
|
||||
16
Tests/CMakeOnly/option/CMakeLists.txt
Normal file
16
Tests/CMakeOnly/option/CMakeLists.txt
Normal file
@@ -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()
|
||||
Reference in New Issue
Block a user