summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/CMP0126/CMP0126-NEW.cmake
blob: 2f8562bb9a9d2d2b727f60d3401475932141d2fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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()