summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/find_program/NO_CACHE.cmake
blob: 77a058260e923a27297c91fe5278608b4617c5a2 (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
find_program(PROG_A
  NAMES testA
  PATHS ${CMAKE_CURRENT_SOURCE_DIR}/A
  NO_CACHE
  NO_DEFAULT_PATH
  )
if (DEFINED CACHE{PROG_A})
  message(SEND_ERROR "Cache variable defined: PROG_A")
endif()
message(STATUS "PROG_A='${PROG_A}'")


find_program(PROG_AandB
  NAMES testAandB
  NO_CACHE
  )
if (DEFINED CACHE{PROG_AandB})
  message(SEND_ERROR "Cache variable defined: PROG_AandN")
endif()
message(STATUS "PROG_AandB='${PROG_AandB}'")


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

set(PROG_cache "unknown" CACHE FILEPATH "")
find_program(PROG_cache
  NAMES testA
  PATHS ${CMAKE_CURRENT_SOURCE_DIR}/A
  NO_CACHE
  NO_DEFAULT_PATH
  )
if (NOT DEFINED CACHE{PROG_cache})
  message(SEND_ERROR "Cache variable not defined: PROG_cache")
endif()
message(STATUS "CACHED PROG_cache='$CACHE{PROG_cache}'")
unset(PROG_cache CACHE)
message(STATUS "PROG_cache='${PROG_cache}'")


set(PROG_cache "testA" CACHE FILEPATH "")
unset(PROG_cache)
find_program(PROG_cache
  NAMES testA
  PATHS ${CMAKE_CURRENT_SOURCE_DIR}/A
  NO_CACHE
  NO_DEFAULT_PATH
  )
if (NOT DEFINED CACHE{PROG_cache})
  message(SEND_ERROR "Cache variable not defined: PROG_cache")
endif()
message(STATUS "CACHED PROG_cache='$CACHE{PROG_cache}'")
unset(PROG_cache CACHE)
message(STATUS "PROG_cache='${PROG_cache}'")


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


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

set(PROG_cache "unknown" CACHE FILEPATH "")
find_program(PROG_cache
  NAMES testA
  PATHS ${CMAKE_CURRENT_SOURCE_DIR}/A
  NO_CACHE
  NO_DEFAULT_PATH
  )
if (NOT DEFINED CACHE{PROG_cache})
  message(SEND_ERROR "Cache variable not defined: PROG_cache")
endif()
message(STATUS "CACHED PROG_cache='$CACHE{PROG_cache}'")
unset(PROG_cache CACHE)
message(STATUS "PROG_cache='${PROG_cache}'")


set(PROG_cache "testA" CACHE FILEPATH "")
unset(PROG_cache)
find_program(PROG_cache
  NAMES testA
  PATHS ${CMAKE_CURRENT_SOURCE_DIR}/A
  NO_CACHE
  NO_DEFAULT_PATH
  )
if (NOT DEFINED CACHE{PROG_cache})
  message(SEND_ERROR "Cache variable not defined: PROG_cache")
endif()
message(STATUS "CACHED PROG_cache='$CACHE{PROG_cache}'")
unset(PROG_cache CACHE)
message(STATUS "PROG_cache='${PROG_cache}'")


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