diff options
author | Brad King <brad.king@kitware.com> | 2021-05-25 14:02:56 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2021-05-25 14:03:03 (GMT) |
commit | bf2717e436ff2fceaaaf3a9e032d5f10c7dc8d06 (patch) | |
tree | 8f1124bf7f5904c1b3c83eb08905b417aa0a5809 /Tests | |
parent | 0c16774fecb8a9ef989f6c0a6705c080ee55d720 (diff) | |
parent | d96eb5528276a19d79116d842389f3ea165ef21b (diff) | |
download | CMake-bf2717e436ff2fceaaaf3a9e032d5f10c7dc8d06.zip CMake-bf2717e436ff2fceaaaf3a9e032d5f10c7dc8d06.tar.gz CMake-bf2717e436ff2fceaaaf3a9e032d5f10c7dc8d06.tar.bz2 |
Merge topic 'set-cache-keep-normal-variable'
d96eb55282 set(CACHE): do not remove normal variable
Acked-by: Kitware Robot <kwrobot@kitware.com>
Reviewed-by: Ben Boeckel <ben.boeckel@kitware.com>
Merge-request: !6146
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/RunCMake/CMP0126/CMP0126-NEW.cmake | 28 | ||||
-rw-r--r-- | Tests/RunCMake/CMP0126/CMP0126-NEW_CL.cmake | 9 | ||||
-rw-r--r-- | Tests/RunCMake/CMP0126/CMP0126-OLD.cmake | 25 | ||||
-rw-r--r-- | Tests/RunCMake/CMP0126/CMP0126-OLD_CL.cmake | 9 | ||||
-rw-r--r-- | Tests/RunCMake/CMP0126/CMakeLists.txt | 3 | ||||
-rw-r--r-- | Tests/RunCMake/CMP0126/RunCMakeTest.cmake | 6 | ||||
-rw-r--r-- | Tests/RunCMake/CMakeLists.txt | 1 |
7 files changed, 81 insertions, 0 deletions
diff --git a/Tests/RunCMake/CMP0126/CMP0126-NEW.cmake b/Tests/RunCMake/CMP0126/CMP0126-NEW.cmake new file mode 100644 index 0000000..2f8562b --- /dev/null +++ b/Tests/RunCMake/CMP0126/CMP0126-NEW.cmake @@ -0,0 +1,28 @@ + +# enforce policy CMP0125 to ensure predictable result of find_* commands +cmake_policy(SET CMP0125 NEW) + +cmake_policy(SET CMP0126 NEW) + +set(VAR 1) +set(VAR 2 CACHE STRING "") + +if (NOT VAR EQUAL 1) + message(FATAL_ERROR "normal variable does not exist anymore.") +endif() + + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/file.txt" "") +set(VAR file.txt) +set(VAR "" CACHE STRING "" FORCE) +set_property(CACHE VAR PROPERTY TYPE UNINITIALIZED) + +find_file(VAR NAMES file.txt PATHS "${CMAKE_CURRENT_BINARY_DIR}") + +unset(VAR CACHE) +if (NOT DEFINED VAR) + message(FATAL_ERROR "find_file: normal variable does not exist anymore.") +endif() +if (NOT VAR STREQUAL "${CMAKE_CURRENT_BINARY_DIR}/file.txt") + message(FATAL_ERROR "find_file: failed to set normal variable.") +endif() diff --git a/Tests/RunCMake/CMP0126/CMP0126-NEW_CL.cmake b/Tests/RunCMake/CMP0126/CMP0126-NEW_CL.cmake new file mode 100644 index 0000000..cfaa1e3 --- /dev/null +++ b/Tests/RunCMake/CMP0126/CMP0126-NEW_CL.cmake @@ -0,0 +1,9 @@ + +cmake_policy(SET CMP0126 NEW) + +set(VAR 1) +set(VAR 2 CACHE STRING "") + +if (NOT VAR EQUAL 1) + message(FATAL_ERROR "normal variable does not exist anymore.") +endif() diff --git a/Tests/RunCMake/CMP0126/CMP0126-OLD.cmake b/Tests/RunCMake/CMP0126/CMP0126-OLD.cmake new file mode 100644 index 0000000..22a5037 --- /dev/null +++ b/Tests/RunCMake/CMP0126/CMP0126-OLD.cmake @@ -0,0 +1,25 @@ + +# enforce policy CMP0125 to ensure predictable result of find_* commands +cmake_policy(SET CMP0125 NEW) + +cmake_policy(SET CMP0126 OLD) + +set(VAR 1) +set(VAR 2 CACHE STRING "") + +if (VAR EQUAL 1) + message(FATAL_ERROR "normal variable still exist.") +endif() + + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/file.txt" "") +set(VAR file.txt) +set(VAR "" CACHE STRING "" FORCE) +set_property(CACHE VAR PROPERTY TYPE UNINITIALIZED) + +find_file(VAR NAMES file.txt PATHS "${CMAKE_CURRENT_BINARY_DIR}") + +unset(VAR CACHE) +if (DEFINED VAR) + message(FATAL_ERROR "find_file: normal variable still exist.") +endif() diff --git a/Tests/RunCMake/CMP0126/CMP0126-OLD_CL.cmake b/Tests/RunCMake/CMP0126/CMP0126-OLD_CL.cmake new file mode 100644 index 0000000..5d72a87 --- /dev/null +++ b/Tests/RunCMake/CMP0126/CMP0126-OLD_CL.cmake @@ -0,0 +1,9 @@ + +cmake_policy(SET CMP0126 OLD) + +set(VAR 1) +set(VAR 2 CACHE STRING "") + +if (NOT VAR EQUAL 3) + message(FATAL_ERROR "normal variable still exist.") +endif() diff --git a/Tests/RunCMake/CMP0126/CMakeLists.txt b/Tests/RunCMake/CMP0126/CMakeLists.txt new file mode 100644 index 0000000..7cabeb6 --- /dev/null +++ b/Tests/RunCMake/CMP0126/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.20) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CMP0126/RunCMakeTest.cmake b/Tests/RunCMake/CMP0126/RunCMakeTest.cmake new file mode 100644 index 0000000..ae988f4 --- /dev/null +++ b/Tests/RunCMake/CMP0126/RunCMakeTest.cmake @@ -0,0 +1,6 @@ +include(RunCMake) + +run_cmake(CMP0126-OLD) +run_cmake_with_options(CMP0126-OLD_CL -DVAR=3) +run_cmake(CMP0126-NEW) +run_cmake_with_options(CMP0126-NEW_CL -DVAR=3) diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index afaeaef..14a7fa3 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -140,6 +140,7 @@ if (CMAKE_SYSTEM_NAME MATCHES "(Linux|Darwin)") add_RunCMake_test(CMP0125 -DCMAKE_SHARED_LIBRARY_PREFIX=${CMAKE_SHARED_LIBRARY_PREFIX} -DCMAKE_SHARED_LIBRARY_SUFFIX=${CMAKE_SHARED_LIBRARY_SUFFIX}) endif() +add_RunCMake_test(CMP0126) # The test for Policy 65 requires the use of the # CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS variable, which both the VS and Xcode |