Files
CMake/Tests/RunCMake/option/CMP0077-SECOND-PASS.cmake
Robert Maynard f8a7cf85ad option: No CMP077 warnings when both cache and local variable exists
Previously we would warn when the local and cache version of a variable
exists, but this use case doesn't need a warning as it maintains backwards
compatibility.
2018-07-10 13:56:15 -04:00

15 lines
514 B
CMake

#Verify that when both a cache and local version of a value exist that CMake
#doesn't produce a CMP0077 warning and that we get the expected values.
option(OPT_LOCAL_VAR "TEST_VAR" ON)
set(OPT_LOCAL_VAR FALSE)
option(OPT_LOCAL_VAR "TEST_VAR" ON)
if(OPT_LOCAL_VAR)
message(FATAL_ERROR "option improperly set a cache variable that already exists")
endif()
get_property(_exists_in_cache CACHE OPT_LOCAL_VAR PROPERTY VALUE SET)
if(NOT _exists_in_cache)
message(FATAL_ERROR "value should exist in cache")
endif()