summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/find_program
diff options
context:
space:
mode:
authorMarc Chevrier <marc.chevrier@gmail.com>2022-04-16 08:57:30 (GMT)
committerMarc Chevrier <marc.chevrier@gmail.com>2022-04-29 20:00:02 (GMT)
commit8d7e80cf3d39ae24a6c88ee07492b9cfe40defd5 (patch)
tree3463bda9324fb4bae11d6c470086b4b942246597 /Tests/RunCMake/find_program
parent08941a9a40c7786aa2ee8ff8e7c684eaf016513e (diff)
downloadCMake-8d7e80cf3d39ae24a6c88ee07492b9cfe40defd5.zip
CMake-8d7e80cf3d39ae24a6c88ee07492b9cfe40defd5.tar.gz
CMake-8d7e80cf3d39ae24a6c88ee07492b9cfe40defd5.tar.bz2
find_* commands: add control over Windows registry views
Fixes: #22775
Diffstat (limited to 'Tests/RunCMake/find_program')
-rwxr-xr-xTests/RunCMake/find_program/32bit/file.exe0
-rwxr-xr-xTests/RunCMake/find_program/32bit/file32bit.exe0
-rwxr-xr-xTests/RunCMake/find_program/64bit/file.exe0
-rwxr-xr-xTests/RunCMake/find_program/64bit/file64bit.exe0
-rw-r--r--Tests/RunCMake/find_program/REGISTRY_VIEW-no-view-result.txt1
-rw-r--r--Tests/RunCMake/find_program/REGISTRY_VIEW-no-view-stderr.txt4
-rw-r--r--Tests/RunCMake/find_program/REGISTRY_VIEW-no-view.cmake2
-rw-r--r--Tests/RunCMake/find_program/REGISTRY_VIEW-wrong-view-result.txt1
-rw-r--r--Tests/RunCMake/find_program/REGISTRY_VIEW-wrong-view-stderr.txt4
-rw-r--r--Tests/RunCMake/find_program/REGISTRY_VIEW-wrong-view.cmake2
-rw-r--r--Tests/RunCMake/find_program/Registry-query.cmake236
-rw-r--r--Tests/RunCMake/find_program/RunCMakeTest.cmake28
-rwxr-xr-xTests/RunCMake/find_program/default.32bit/file.exe0
-rwxr-xr-xTests/RunCMake/find_program/default.32bit/file32bit.exe0
-rwxr-xr-xTests/RunCMake/find_program/default.64bit/file.exe0
-rwxr-xr-xTests/RunCMake/find_program/default.64bit/file64bit.exe0
-rw-r--r--Tests/RunCMake/find_program/registry_host32bit.regbin0 -> 298 bytes
-rw-r--r--Tests/RunCMake/find_program/registry_host64bit.regbin0 -> 542 bytes
18 files changed, 278 insertions, 0 deletions
diff --git a/Tests/RunCMake/find_program/32bit/file.exe b/Tests/RunCMake/find_program/32bit/file.exe
new file mode 100755
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/find_program/32bit/file.exe
diff --git a/Tests/RunCMake/find_program/32bit/file32bit.exe b/Tests/RunCMake/find_program/32bit/file32bit.exe
new file mode 100755
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/find_program/32bit/file32bit.exe
diff --git a/Tests/RunCMake/find_program/64bit/file.exe b/Tests/RunCMake/find_program/64bit/file.exe
new file mode 100755
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/find_program/64bit/file.exe
diff --git a/Tests/RunCMake/find_program/64bit/file64bit.exe b/Tests/RunCMake/find_program/64bit/file64bit.exe
new file mode 100755
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/find_program/64bit/file64bit.exe
diff --git a/Tests/RunCMake/find_program/REGISTRY_VIEW-no-view-result.txt b/Tests/RunCMake/find_program/REGISTRY_VIEW-no-view-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/find_program/REGISTRY_VIEW-no-view-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/find_program/REGISTRY_VIEW-no-view-stderr.txt b/Tests/RunCMake/find_program/REGISTRY_VIEW-no-view-stderr.txt
new file mode 100644
index 0000000..dbe38a1
--- /dev/null
+++ b/Tests/RunCMake/find_program/REGISTRY_VIEW-no-view-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at REGISTRY_VIEW-no-view.cmake:[0-9]+ \(find_program\):
+ find_program missing required argument for "REGISTRY_VIEW"
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/find_program/REGISTRY_VIEW-no-view.cmake b/Tests/RunCMake/find_program/REGISTRY_VIEW-no-view.cmake
new file mode 100644
index 0000000..1dc6659
--- /dev/null
+++ b/Tests/RunCMake/find_program/REGISTRY_VIEW-no-view.cmake
@@ -0,0 +1,2 @@
+
+find_program(result NAMES input.txt REGISTRY_VIEW)
diff --git a/Tests/RunCMake/find_program/REGISTRY_VIEW-wrong-view-result.txt b/Tests/RunCMake/find_program/REGISTRY_VIEW-wrong-view-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/find_program/REGISTRY_VIEW-wrong-view-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/find_program/REGISTRY_VIEW-wrong-view-stderr.txt b/Tests/RunCMake/find_program/REGISTRY_VIEW-wrong-view-stderr.txt
new file mode 100644
index 0000000..de07095
--- /dev/null
+++ b/Tests/RunCMake/find_program/REGISTRY_VIEW-wrong-view-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at REGISTRY_VIEW-wrong-view.cmake:[0-9]+ \(find_program\):
+ find_program given invalid value for "REGISTRY_VIEW": WRONG_VIEW
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/find_program/REGISTRY_VIEW-wrong-view.cmake b/Tests/RunCMake/find_program/REGISTRY_VIEW-wrong-view.cmake
new file mode 100644
index 0000000..110fd9a
--- /dev/null
+++ b/Tests/RunCMake/find_program/REGISTRY_VIEW-wrong-view.cmake
@@ -0,0 +1,2 @@
+
+find_program(result NAMES input.txt REGISTRY_VIEW WRONG_VIEW)
diff --git a/Tests/RunCMake/find_program/Registry-query.cmake b/Tests/RunCMake/find_program/Registry-query.cmake
new file mode 100644
index 0000000..0e1f2a5
--- /dev/null
+++ b/Tests/RunCMake/find_program/Registry-query.cmake
@@ -0,0 +1,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()
diff --git a/Tests/RunCMake/find_program/RunCMakeTest.cmake b/Tests/RunCMake/find_program/RunCMakeTest.cmake
index c2c07af..d0ce8fc 100644
--- a/Tests/RunCMake/find_program/RunCMakeTest.cmake
+++ b/Tests/RunCMake/find_program/RunCMakeTest.cmake
@@ -7,6 +7,8 @@ run_cmake(RelAndAbsPath)
run_cmake(Required)
run_cmake(NO_CACHE)
run_cmake(IgnorePrefixPath)
+run_cmake(REGISTRY_VIEW-no-view)
+run_cmake(REGISTRY_VIEW-wrong-view)
if(CMAKE_SYSTEM_NAME MATCHES "^(Windows|CYGWIN|MSYS)$")
run_cmake(WindowsCom)
@@ -30,3 +32,29 @@ if(APPLE)
endif()
run_cmake_with_options(EnvAndHintsDebugVar --debug-find-var=PROG)
+
+if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
+ # Tests using the Windows registry
+ find_program(REG NAMES "reg.exe" NO_CACHE)
+ if (REG)
+ ## check host architecture
+ cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "HKCU" SUBKEYS VIEW 64 ERROR_VARIABLE status)
+ if (status STREQUAL "")
+ set(ARCH "64bit")
+ else()
+ set(ARCH "32bit")
+ endif()
+
+ # crete some entries in the registry
+ cmake_path(CONVERT "${RunCMake_SOURCE_DIR}/registry_host${ARCH}.reg" TO_NATIVE_PATH_LIST registry_data)
+ execute_process(COMMAND "${REG}" import "${registry_data}" OUTPUT_QUIET ERROR_QUIET)
+
+ run_cmake_with_options(Registry-query -DARCH=${ARCH})
+
+ # clean-up registry
+ execute_process(COMMAND "${REG}" delete "HKCU\\SOFTWARE\\Classes\\CLSID\\CMake-Tests\\find_program" /f OUTPUT_QUIET ERROR_QUIET)
+ if (ARCH STREQUAL "64bit")
+ execute_process(COMMAND "${REG}" delete "HKCU\\SOFTWARE\\Classes\\WOW6432Node\\CLSID\\CMake-Tests\\find_program" /f OUTPUT_QUIET ERROR_QUIET)
+ endif()
+ endif()
+endif()
diff --git a/Tests/RunCMake/find_program/default.32bit/file.exe b/Tests/RunCMake/find_program/default.32bit/file.exe
new file mode 100755
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/find_program/default.32bit/file.exe
diff --git a/Tests/RunCMake/find_program/default.32bit/file32bit.exe b/Tests/RunCMake/find_program/default.32bit/file32bit.exe
new file mode 100755
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/find_program/default.32bit/file32bit.exe
diff --git a/Tests/RunCMake/find_program/default.64bit/file.exe b/Tests/RunCMake/find_program/default.64bit/file.exe
new file mode 100755
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/find_program/default.64bit/file.exe
diff --git a/Tests/RunCMake/find_program/default.64bit/file64bit.exe b/Tests/RunCMake/find_program/default.64bit/file64bit.exe
new file mode 100755
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/find_program/default.64bit/file64bit.exe
diff --git a/Tests/RunCMake/find_program/registry_host32bit.reg b/Tests/RunCMake/find_program/registry_host32bit.reg
new file mode 100644
index 0000000..4c904c9
--- /dev/null
+++ b/Tests/RunCMake/find_program/registry_host32bit.reg
Binary files differ
diff --git a/Tests/RunCMake/find_program/registry_host64bit.reg b/Tests/RunCMake/find_program/registry_host64bit.reg
new file mode 100644
index 0000000..1a8fe54
--- /dev/null
+++ b/Tests/RunCMake/find_program/registry_host64bit.reg
Binary files differ