summaryrefslogtreecommitdiff
path: root/Tests/RunCMake/find_path/NO_CACHE.cmake
blob: 4779ac8a7cde6d62dfb502bfd991186e22711623 (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
130
131
find_path(PATH_exists
  NAMES PrefixInPATH.h
  PATHS ${CMAKE_CURRENT_SOURCE_DIR}/include
  NO_CACHE
  NO_DEFAULT_PATH
  )
if (DEFINED CACHE{PATH_exists})
  message(SEND_ERROR "Cache variable defined: PATH_exists")
endif()
message(STATUS "PATH_exists='${PATH_exists}'")


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


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

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


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


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


cmake_policy(SET CMP0125 NEW)
message(STATUS "")
message(STATUS "Policy CMP0125 = NEW")
file(REMOVE_RECURSE "${CMAKE_BINARY_DIR}/include")

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


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


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