blob: 0e1f2a5c83a8941b0e71583904ec556f582f6419 (
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
|
# helper function for test validation
function(CHECK query result expression)
cmake_language(EVAL CODE
"if (NOT (${expression}))
message(SEND_ERROR \"wrong value for query '${query}': '${result}'\")
endif()")
endfunction()
cmake_policy(SET CMP0134 NEW)
# HKCU/Software/Classes/CLSID/CMake-Tests/find_program: Query default value
set(FILE_DIR "[HKCU/Software/Classes/CLSID/CMake-Tests/find_program]")
set(FILE_DIR2 "[HKCU/Software/Classes/CLSID/CMake-Tests/find_program;(default)]")
unset(result)
find_program(result NAMES file.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REQUIRED NO_CACHE NO_DEFAULT_PATH)
check("${FILE_DIR}" "${result}" "result MATCHES \"default.${ARCH}/file.exe$\"")
# query value using special name should be identical to default value
unset(result)
find_program(result NAMES file.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR2}" REQUIRED NO_CACHE NO_DEFAULT_PATH)
check("${FILE_DIR2}" "${result}" "result MATCHES \"default.${ARCH}/file.exe$\"")
unset(result)
find_program(result NAMES file.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW HOST REQUIRED NO_CACHE NO_DEFAULT_PATH)
check("${FILE_DIR}" "${result}" "result MATCHES \"default.${ARCH}/file.exe$\"")
# VIEW TARGET should have same value as VIEW HOST
unset(result2)
find_program(result2 NAMES file.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW TARGET REQUIRED NO_CACHE NO_DEFAULT_PATH)
check("${FILE_DIR}" "${result2}" "result2 STREQUAL result")
if (ARCH STREQUAL "64bit")
# default view is BOTH so querying any value specific to 32 or 64bit must be found
unset(result)
find_program(result NAMES file64bit.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REQUIRED NO_CACHE NO_DEFAULT_PATH)
check("${FILE_DIR}" "${result}" "result MATCHES \"default.64bit/file64bit.exe$\"")
unset(result)
find_program(result NAMES file32bit.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REQUIRED NO_CACHE NO_DEFAULT_PATH)
check("${FILE_DIR}" "${result}" "result MATCHES \"default.32bit/file32bit.exe$\"")
unset(result)
find_program(result NAMES file.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64 REQUIRED NO_CACHE NO_DEFAULT_PATH)
check("${FILE_DIR}" "${result}" "result MATCHES \"default.64bit/file.exe$\"")
unset(result)
find_program(result NAMES file.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32 REQUIRED NO_CACHE NO_DEFAULT_PATH)
check("${FILE_DIR}" "${result}" "result MATCHES \"default.32bit/file.exe$\"")
unset(result)
find_program(result NAMES file.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64_32 REQUIRED NO_CACHE NO_DEFAULT_PATH)
check("${FILE_DIR}" "${result}" "result MATCHES \"default.64bit/file.exe$\"")
unset(result)
find_program(result NAMES file.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32_64 REQUIRED NO_CACHE NO_DEFAULT_PATH)
check("${FILE_DIR}" "${result}" "result MATCHES \"default.32bit/file.exe$\"")
# check the second view is taken into account
unset(result)
find_program(result NAMES file32bit.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64_32 REQUIRED NO_CACHE NO_DEFAULT_PATH)
check("${FILE_DIR}" "${result}" "result MATCHES \"default.32bit/file32bit.exe$\"")
unset(result)
find_program(result NAMES file64bit.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32_64 REQUIRED NO_CACHE NO_DEFAULT_PATH)
check("${FILE_DIR}" "${result}" "result MATCHES \"default.64bit/file64bit.exe$\"")
# check the both views are taken into account
unset(result)
find_program(result NAMES file32bit.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW BOTH REQUIRED NO_CACHE NO_DEFAULT_PATH)
check("${FILE_DIR}" "${result}" "result MATCHES \"default.32bit/file32bit.exe$\"")
unset(result)
find_program(result NAMES file64bit.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW BOTH REQUIRED NO_CACHE NO_DEFAULT_PATH)
check("${FILE_DIR}" "${result}" "result MATCHES \"default.64bit/file64bit.exe$\"")
else() # 32bit
# no 64bit registry: file not found
unset(result)
find_program(result NAMES file.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64 NO_CACHE NO_DEFAULT_PATH)
check("${FILE_DIR}" "${result}" "result MATCHES \"result-NOTFOUND$\"")
unset(result)
find_program(result NAMES file.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32 REQUIRED NO_CACHE NO_DEFAULT_PATH)
check("${FILE_DIR}" "${result}" "result MATCHES \"default.32bit/file.exe$\"")
# views 64_32 and 32_64 give same result
unset(result)
find_program(result NAMES file.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64_32 REQUIRED NO_CACHE NO_DEFAULT_PATH)
check("${FILE_DIR}" "${result}" "result MATCHES \"default.32bit/file.exe$\"")
unset(result)
find_program(result NAMES file.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32_64 REQUIRED NO_CACHE NO_DEFAULT_PATH)
check("${FILE_DIR}" "${result}" "result MATCHES \"default.32bit/file.exe$\"")
# check the both views are usable on 32bit platforms
unset(result)
find_program(result NAMES file.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW BOTH REQUIRED NO_CACHE NO_DEFAULT_PATH)
check("${FILE_DIR}" "${result}" "result MATCHES \"default.32bit/file.exe$\"")
endif()
# HKCU/Software/Classes/CLSID/CMake-Tests/find_program: Query specific value
set(FILE_DIR "[{|}HKCU/Software/Classes/CLSID/CMake-Tests/find_program|FILE_DIR]")
set(FILE_DIR2 "[HKCU\\Software\\Classes\\CLSID\\CMake-Tests\\find_program;FILE_DIR]")
unset(result)
find_program(result NAMES file.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REQUIRED NO_CACHE NO_DEFAULT_PATH)
check("${FILE_DIR}" "${result}" "result MATCHES \"/${ARCH}/file.exe$\"")
# query value using special name should be identical to default value
unset(result)
find_program(result NAMES file.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR2}" REQUIRED NO_CACHE NO_DEFAULT_PATH)
check("${FILE_DIR2}" "${result}" "result MATCHES \"/${ARCH}/file.exe$\"")
unset(result)
find_program(result NAMES file.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW HOST REQUIRED NO_CACHE NO_DEFAULT_PATH)
check("${FILE_DIR}" "${result}" "result MATCHES \"/${ARCH}/file.exe$\"")
# VIEW TARGET should have same value as VIEW HOST
unset(result2)
find_program(result2 NAMES file.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW TARGET REQUIRED NO_CACHE NO_DEFAULT_PATH)
check("${FILE_DIR}" "${result2}" "result2 STREQUAL result")
if (ARCH STREQUAL "64bit")
# default view is BOTH so querying any value specific to 32 or 64bit must be found
unset(result)
find_program(result NAMES file64bit.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REQUIRED NO_CACHE NO_DEFAULT_PATH)
check("${FILE_DIR}" "${result}" "result MATCHES \"/64bit/file64bit.exe$\"")
unset(result)
find_program(result NAMES file32bit.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REQUIRED NO_CACHE NO_DEFAULT_PATH)
check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/file32bit.exe$\"")
unset(result)
find_program(result NAMES file.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64 REQUIRED NO_CACHE NO_DEFAULT_PATH)
check("${FILE_DIR}" "${result}" "result MATCHES \"/64bit/file.exe$\"")
unset(result)
find_program(result NAMES file.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32 REQUIRED NO_CACHE NO_DEFAULT_PATH)
check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/file.exe$\"")
unset(result)
find_program(result NAMES file.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64_32 REQUIRED NO_CACHE NO_DEFAULT_PATH)
check("${FILE_DIR}" "${result}" "result MATCHES \"/64bit/file.exe$\"")
unset(result)
find_program(result NAMES file.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32_64 REQUIRED NO_CACHE NO_DEFAULT_PATH)
check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/file.exe$\"")
# check the second view is taken into account
unset(result)
find_program(result NAMES file32bit.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64_32 NO_CACHE NO_DEFAULT_PATH)
check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/file32bit.exe$\"")
unset(result)
find_program(result NAMES file64bit.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32_64 REQUIRED NO_CACHE NO_DEFAULT_PATH)
check("${FILE_DIR}" "${result}" "result MATCHES \"/64bit/file64bit.exe$\"")
# check the both views are taken into account
unset(result)
find_program(result NAMES file32bit.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW BOTH REQUIRED NO_CACHE NO_DEFAULT_PATH)
check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/file32bit.exe$\"")
unset(result)
find_program(result NAMES file64bit.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW BOTH REQUIRED NO_CACHE NO_DEFAULT_PATH)
check("${FILE_DIR}" "${result}" "result MATCHES \"/64bit/file64bit.exe$\"")
else() # 32bit
# no 64bit registry: file not found
unset(result)
find_program(result NAMES file.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64 NO_CACHE NO_DEFAULT_PATH)
check("${FILE_DIR}" "${result}" "result MATCHES \"result-NOTFOUND$\"")
unset(result)
find_program(result NAMES file.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32 REQUIRED NO_CACHE NO_DEFAULT_PATH)
check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/file.exe$\"")
unset(result)
find_program(result NAMES file.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64_32 REQUIRED NO_CACHE NO_DEFAULT_PATH)
check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/file.exe$\"")
unset(result)
find_program(result NAMES file.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32_64 REQUIRED NO_CACHE NO_DEFAULT_PATH)
check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/file.exe$\"")
# check the both views are taken into account
unset(result)
find_program(result NAMES file.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW BOTH REQUIRED NO_CACHE NO_DEFAULT_PATH)
check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/file.exe$\"")
endif()
if (ARCH STREQUAL "64bit")
# Check influence of variable CMAKE_SIZEOF_VOID_P
set(CMAKE_SIZEOF_VOID_P 8)
unset(result)
find_program(result NAMES file.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW TARGET REQUIRED NO_CACHE NO_DEFAULT_PATH)
check("${FILE_DIR}" "${result}" "result MATCHES \"/64bit/file.exe$\"")
unset(result)
find_program(result NAMES file.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW HOST REQUIRED NO_CACHE NO_DEFAULT_PATH)
check("${FILE_DIR}" "${result}" "result MATCHES \"/${ARCH}/file.exe$\"")
set(CMAKE_SIZEOF_VOID_P 4)
unset(result)
find_program(result NAMES file.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW TARGET REQUIRED NO_CACHE NO_DEFAULT_PATH)
check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/file.exe$\"")
unset(result)
find_program(result NAMES file.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW HOST REQUIRED NO_CACHE NO_DEFAULT_PATH)
check("${FILE_DIR}" "${result}" "result MATCHES \"/${ARCH}/file.exe$\"")
unset(CMAKE_SIZEOF_VOID_P)
# Check influence of CMP0134 policy with OLD value
cmake_policy(SET CMP0134 OLD)
# CMAKE_SIZEOF_VOID_P is not set, so search first 32bit registry
unset(result)
find_program(result NAMES file.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" NO_CACHE REQUIRED NO_DEFAULT_PATH)
check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/file.exe$\"")
cmake_policy(SET CMP0134 NEW)
# CMAKE_SIZEOF_VOID_P is not set, so search first the HOST architecture registry
unset(result)
find_program(result NAMES file.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" NO_CACHE REQUIRED NO_DEFAULT_PATH)
check("${FILE_DIR}" "${result}" "result MATCHES \"/${ARCH}/file.exe$\"")
endif()
|