summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/find_file/NO_CACHE.cmake
blob: 65156b95877b3bbd6ebf20bce56e1915c8a7cfe2 (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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
find_file(FILE_exists
  NAMES PrefixInPATH.h
  PATHS ${CMAKE_CURRENT_SOURCE_DIR}/include
  NO_CACHE
  NO_DEFAULT_PATH
  )
if (DEFINED CACHE{FILE_exists})
  message(SEND_ERROR "Cache variable defined: FILE_exists")
endif()
message(STATUS "FILE_exists='${FILE_exists}'")


find_file(FILE_doNotExists
  NAMES doNotExists.h
  NO_CACHE
  )
if (DEFINED CACHE{FILE_doNotExists})
  message(SEND_ERROR "Cache variable defined: FILE_doNotExists")
endif()
message(STATUS "FILE_doNotExists='${FILE_doNotExists}'")


cmake_policy(SET CMP0125 OLD)
message(STATUS "")
message(STATUS "Policy CMP0125 = OLD")
file(REMOVE "${CMAKE_BINARY_DIR}/PrefixInPATH.h")

set(FILE_cache "unknown" CACHE FILEPATH "")
find_file(FILE_cache
  NAMES PrefixInPATH.h
  PATHS ${CMAKE_CURRENT_SOURCE_DIR}/include
  NO_CACHE
  NO_DEFAULT_PATH
  )
if (NOT DEFINED CACHE{FILE_cache})
  message(SEND_ERROR "Cache variable not defined: FILE_cache")
endif()
message(STATUS "CACHED FILE_cache='$CACHE{FILE_cache}'")
unset(FILE_cache CACHE)
message(STATUS "FILE_cache='${FILE_cache}'")


set(FILE_cache "PrefixInPATH.h" CACHE FILEPATH "")
unset(FILE_cache)
find_file(FILE_cache
  NAMES PrefixInPATH.h
  PATHS ${CMAKE_CURRENT_SOURCE_DIR}/include
  NO_CACHE
  NO_DEFAULT_PATH
  )
if (NOT DEFINED CACHE{FILE_cache})
  message(SEND_ERROR "Cache variable not defined: FILE_cache")
endif()
message(STATUS "CACHED FILE_cache='$CACHE{FILE_cache}'")
unset(FILE_cache CACHE)
message(STATUS "FILE_cache='${FILE_cache}'")


set(FILE_cache "PrefixInPATH.h" CACHE FILEPATH "")
unset(FILE_cache)
# simulate cache variable defined in command line
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/include/PrefixInPATH.h" DESTINATION "${CMAKE_BINARY_DIR}")
set_property(CACHE FILE_cache PROPERTY TYPE UNINITIALIZED)
find_file(FILE_cache
  NAMES PrefixInPATH.h
  NO_CACHE
  NO_DEFAULT_PATH
  )
if (NOT DEFINED CACHE{FILE_cache})
  message(SEND_ERROR "Cache variable not defined: FILE_cache")
endif()
message(STATUS "CACHED FILE_cache='$CACHE{FILE_cache}'")
unset(FILE_cache CACHE)
message(STATUS "FILE_cache='${FILE_cache}'")


cmake_policy(SET CMP0125 NEW)
message(STATUS "")
message(STATUS "Policy CMP0125 = NEW")
file(REMOVE "${CMAKE_BINARY_DIR}/PrefixInPATH.h")

set(FILE_cache "unknown" CACHE FILEPATH "")
unset(FILE_cache)
find_file(FILE_cache
  NAMES PrefixInPATH.h
  PATHS ${CMAKE_CURRENT_SOURCE_DIR}/include
  NO_CACHE
  NO_DEFAULT_PATH
  )
if (NOT DEFINED CACHE{FILE_cache})
  message(SEND_ERROR "Cache variable not defined: FILE_cache")
endif()
message(STATUS "CACHED FILE_cache='$CACHE{FILE_cache}'")
unset(FILE_cache CACHE)
message(STATUS "FILE_cache='${FILE_cache}'")


set(FILE_cache "PrefixInPATH.h" CACHE FILEPATH "")
unset(FILE_cache)
find_file(FILE_cache
  NAMES PrefixInPATH.h
  PATHS ${CMAKE_CURRENT_SOURCE_DIR}/include
  NO_CACHE
  NO_DEFAULT_PATH
  )
if (NOT DEFINED CACHE{FILE_cache})
  message(SEND_ERROR "Cache variable not defined: FILE_cache")
endif()
message(STATUS "CACHED FILE_cache='$CACHE{FILE_cache}'")
unset(FILE_cache CACHE)
message(STATUS "FILE_cache='${FILE_cache}'")


set(FILE_cache "PrefixInPATH.h" CACHE FILEPATH "")
unset(FILE_cache)
# simulate cache variable defined in command line
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/include/PrefixInPATH.h" DESTINATION "${CMAKE_BINARY_DIR}")
set_property(CACHE FILE_cache PROPERTY TYPE UNINITIALIZED)
find_file(FILE_cache
  NAMES PrefixInPATH.h
  NO_CACHE
  NO_DEFAULT_PATH
  )
if (NOT DEFINED CACHE{FILE_cache})
  message(SEND_ERROR "Cache variable not defined: FILE_cache")
endif()
message(STATUS "CACHED FILE_cache='$CACHE{FILE_cache}'")
unset(FILE_cache CACHE)
message(STATUS "FILE_cache='${FILE_cache}'")