1
2# enforce policy CMP0125 to ensure predictable result of find_* commands
3cmake_policy(SET CMP0125 NEW)
4
5cmake_policy(SET CMP0126 NEW)
6
7set(VAR 1)
8set(VAR 2 CACHE STRING "")
9
10if (NOT VAR EQUAL 1)
11  message(FATAL_ERROR "normal variable does not exist anymore.")
12endif()
13
14
15file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/file.txt" "")
16set(VAR file.txt)
17set(VAR "" CACHE STRING "" FORCE)
18set_property(CACHE VAR PROPERTY TYPE UNINITIALIZED)
19
20find_file(VAR NAMES file.txt PATHS "${CMAKE_CURRENT_BINARY_DIR}")
21
22unset(VAR CACHE)
23if (NOT DEFINED VAR)
24  message(FATAL_ERROR "find_file: normal variable does not exist anymore.")
25endif()
26if (NOT VAR STREQUAL "${CMAKE_CURRENT_BINARY_DIR}/file.txt")
27  message(FATAL_ERROR "find_file: failed to set normal variable.")
28endif()
29