summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake
diff options
context:
space:
mode:
Diffstat (limited to 'Tests/RunCMake')
-rw-r--r--Tests/RunCMake/find_file/32bit/file.txt0
-rw-r--r--Tests/RunCMake/find_file/32bit/file32bit.txt0
-rw-r--r--Tests/RunCMake/find_file/64bit/file.txt0
-rw-r--r--Tests/RunCMake/find_file/64bit/file64bit.txt0
-rw-r--r--Tests/RunCMake/find_file/REGISTRY_VIEW-no-view-result.txt1
-rw-r--r--Tests/RunCMake/find_file/REGISTRY_VIEW-no-view-stderr.txt4
-rw-r--r--Tests/RunCMake/find_file/REGISTRY_VIEW-no-view.cmake2
-rw-r--r--Tests/RunCMake/find_file/REGISTRY_VIEW-wrong-view-result.txt1
-rw-r--r--Tests/RunCMake/find_file/REGISTRY_VIEW-wrong-view-stderr.txt4
-rw-r--r--Tests/RunCMake/find_file/REGISTRY_VIEW-wrong-view.cmake2
-rw-r--r--Tests/RunCMake/find_file/Registry-query.cmake218
-rw-r--r--Tests/RunCMake/find_file/RunCMakeTest.cmake28
-rw-r--r--Tests/RunCMake/find_file/default.32bit/file.txt0
-rw-r--r--Tests/RunCMake/find_file/default.32bit/file32bit.txt0
-rw-r--r--Tests/RunCMake/find_file/default.64bit/file.txt0
-rw-r--r--Tests/RunCMake/find_file/default.64bit/file64bit.txt0
-rw-r--r--Tests/RunCMake/find_file/registry_host32bit.regbin0 -> 292 bytes
-rw-r--r--Tests/RunCMake/find_file/registry_host64bit.regbin0 -> 530 bytes
-rw-r--r--Tests/RunCMake/find_library/32bit/file.lib0
-rw-r--r--Tests/RunCMake/find_library/32bit/file32bit.lib0
-rw-r--r--Tests/RunCMake/find_library/64bit/file.lib0
-rw-r--r--Tests/RunCMake/find_library/64bit/file64bit.lib0
-rw-r--r--Tests/RunCMake/find_library/REGISTRY_VIEW-no-view-result.txt1
-rw-r--r--Tests/RunCMake/find_library/REGISTRY_VIEW-no-view-stderr.txt4
-rw-r--r--Tests/RunCMake/find_library/REGISTRY_VIEW-no-view.cmake2
-rw-r--r--Tests/RunCMake/find_library/REGISTRY_VIEW-wrong-view-result.txt1
-rw-r--r--Tests/RunCMake/find_library/REGISTRY_VIEW-wrong-view-stderr.txt4
-rw-r--r--Tests/RunCMake/find_library/REGISTRY_VIEW-wrong-view.cmake2
-rw-r--r--Tests/RunCMake/find_library/Registry-query.cmake218
-rw-r--r--Tests/RunCMake/find_library/RunCMakeTest.cmake28
-rw-r--r--Tests/RunCMake/find_library/default.32bit/file.lib0
-rw-r--r--Tests/RunCMake/find_library/default.32bit/file32bit.lib0
-rw-r--r--Tests/RunCMake/find_library/default.64bit/file.lib0
-rw-r--r--Tests/RunCMake/find_library/default.64bit/file64bit.lib0
-rw-r--r--Tests/RunCMake/find_library/registry_host32bit.regbin0 -> 298 bytes
-rw-r--r--Tests/RunCMake/find_library/registry_host64bit.regbin0 -> 542 bytes
-rw-r--r--Tests/RunCMake/find_package/32bit/RegistryView32Config.cmake4
-rw-r--r--Tests/RunCMake/find_package/32bit/RegistryViewConfig.cmake4
-rw-r--r--Tests/RunCMake/find_package/64bit/RegistryView64Config.cmake4
-rw-r--r--Tests/RunCMake/find_package/64bit/RegistryViewConfig.cmake4
-rw-r--r--Tests/RunCMake/find_package/FindRegistryView.cmake11
-rw-r--r--Tests/RunCMake/find_package/REGISTRY_VIEW-no-view-result.txt1
-rw-r--r--Tests/RunCMake/find_package/REGISTRY_VIEW-no-view-stderr.txt4
-rw-r--r--Tests/RunCMake/find_package/REGISTRY_VIEW-no-view.cmake2
-rw-r--r--Tests/RunCMake/find_package/REGISTRY_VIEW-propagated.cmake16
-rw-r--r--Tests/RunCMake/find_package/REGISTRY_VIEW-wrong-view-result.txt1
-rw-r--r--Tests/RunCMake/find_package/REGISTRY_VIEW-wrong-view-stderr.txt4
-rw-r--r--Tests/RunCMake/find_package/REGISTRY_VIEW-wrong-view.cmake2
-rw-r--r--Tests/RunCMake/find_package/Registry-query.cmake216
-rw-r--r--Tests/RunCMake/find_package/RunCMakeTest.cmake30
-rw-r--r--Tests/RunCMake/find_package/default.32bit/RegistryView32Config.cmake4
-rw-r--r--Tests/RunCMake/find_package/default.32bit/RegistryViewConfig.cmake4
-rw-r--r--Tests/RunCMake/find_package/default.64bit/RegistryView64Config.cmake4
-rw-r--r--Tests/RunCMake/find_package/default.64bit/RegistryViewConfig.cmake4
-rw-r--r--Tests/RunCMake/find_package/registry_host32bit.regbin0 -> 298 bytes
-rw-r--r--Tests/RunCMake/find_package/registry_host64bit.regbin0 -> 542 bytes
-rw-r--r--Tests/RunCMake/find_path/32bit/file.txt0
-rw-r--r--Tests/RunCMake/find_path/32bit/file32bit.txt0
-rw-r--r--Tests/RunCMake/find_path/64bit/file.txt0
-rw-r--r--Tests/RunCMake/find_path/64bit/file64bit.txt0
-rw-r--r--Tests/RunCMake/find_path/REGISTRY_VIEW-no-view-result.txt1
-rw-r--r--Tests/RunCMake/find_path/REGISTRY_VIEW-no-view-stderr.txt4
-rw-r--r--Tests/RunCMake/find_path/REGISTRY_VIEW-no-view.cmake2
-rw-r--r--Tests/RunCMake/find_path/REGISTRY_VIEW-wrong-view-result.txt1
-rw-r--r--Tests/RunCMake/find_path/REGISTRY_VIEW-wrong-view-stderr.txt4
-rw-r--r--Tests/RunCMake/find_path/REGISTRY_VIEW-wrong-view.cmake2
-rw-r--r--Tests/RunCMake/find_path/Registry-query.cmake218
-rw-r--r--Tests/RunCMake/find_path/RunCMakeTest.cmake28
-rw-r--r--Tests/RunCMake/find_path/default.32bit/file.txt0
-rw-r--r--Tests/RunCMake/find_path/default.32bit/file32bit.txt0
-rw-r--r--Tests/RunCMake/find_path/default.64bit/file.txt0
-rw-r--r--Tests/RunCMake/find_path/default.64bit/file64bit.txt0
-rw-r--r--Tests/RunCMake/find_path/registry_host32bit.regbin0 -> 292 bytes
-rw-r--r--Tests/RunCMake/find_path/registry_host64bit.regbin0 -> 530 bytes
-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
92 files changed, 1377 insertions, 0 deletions
diff --git a/Tests/RunCMake/find_file/32bit/file.txt b/Tests/RunCMake/find_file/32bit/file.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/find_file/32bit/file.txt
diff --git a/Tests/RunCMake/find_file/32bit/file32bit.txt b/Tests/RunCMake/find_file/32bit/file32bit.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/find_file/32bit/file32bit.txt
diff --git a/Tests/RunCMake/find_file/64bit/file.txt b/Tests/RunCMake/find_file/64bit/file.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/find_file/64bit/file.txt
diff --git a/Tests/RunCMake/find_file/64bit/file64bit.txt b/Tests/RunCMake/find_file/64bit/file64bit.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/find_file/64bit/file64bit.txt
diff --git a/Tests/RunCMake/find_file/REGISTRY_VIEW-no-view-result.txt b/Tests/RunCMake/find_file/REGISTRY_VIEW-no-view-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/find_file/REGISTRY_VIEW-no-view-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/find_file/REGISTRY_VIEW-no-view-stderr.txt b/Tests/RunCMake/find_file/REGISTRY_VIEW-no-view-stderr.txt
new file mode 100644
index 0000000..28e3e12
--- /dev/null
+++ b/Tests/RunCMake/find_file/REGISTRY_VIEW-no-view-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at REGISTRY_VIEW-no-view.cmake:[0-9]+ \(find_file\):
+ find_file missing required argument for "REGISTRY_VIEW"
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/find_file/REGISTRY_VIEW-no-view.cmake b/Tests/RunCMake/find_file/REGISTRY_VIEW-no-view.cmake
new file mode 100644
index 0000000..fc24f7b
--- /dev/null
+++ b/Tests/RunCMake/find_file/REGISTRY_VIEW-no-view.cmake
@@ -0,0 +1,2 @@
+
+find_file(result NAMES input.txt REGISTRY_VIEW)
diff --git a/Tests/RunCMake/find_file/REGISTRY_VIEW-wrong-view-result.txt b/Tests/RunCMake/find_file/REGISTRY_VIEW-wrong-view-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/find_file/REGISTRY_VIEW-wrong-view-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/find_file/REGISTRY_VIEW-wrong-view-stderr.txt b/Tests/RunCMake/find_file/REGISTRY_VIEW-wrong-view-stderr.txt
new file mode 100644
index 0000000..42843f3
--- /dev/null
+++ b/Tests/RunCMake/find_file/REGISTRY_VIEW-wrong-view-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at REGISTRY_VIEW-wrong-view.cmake:[0-9]+ \(find_file\):
+ find_file 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_file/REGISTRY_VIEW-wrong-view.cmake b/Tests/RunCMake/find_file/REGISTRY_VIEW-wrong-view.cmake
new file mode 100644
index 0000000..a2c73d6
--- /dev/null
+++ b/Tests/RunCMake/find_file/REGISTRY_VIEW-wrong-view.cmake
@@ -0,0 +1,2 @@
+
+find_file(result NAMES input.txt REGISTRY_VIEW WRONG_VIEW)
diff --git a/Tests/RunCMake/find_file/Registry-query.cmake b/Tests/RunCMake/find_file/Registry-query.cmake
new file mode 100644
index 0000000..ea2f0f1
--- /dev/null
+++ b/Tests/RunCMake/find_file/Registry-query.cmake
@@ -0,0 +1,218 @@
+
+# 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_file: Query default value
+set(FILE_DIR "[HKCU/Software/Classes/CLSID/CMake-Tests/find_file]")
+set(FILE_DIR2 "[HKCU/Software/Classes/CLSID/CMake-Tests/find_file;(default)]")
+
+unset(result)
+find_file(result NAMES file.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REQUIRED NO_CACHE NO_DEFAULT_PATH)
+check("${FILE_DIR}" "${result}" "result MATCHES \"default.${ARCH}/file.txt$\"")
+
+# query value using special name should be identical to default value
+unset(result)
+find_file(result NAMES file.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR2}" REQUIRED NO_CACHE NO_DEFAULT_PATH)
+check("${FILE_DIR2}" "${result}" "result MATCHES \"default.${ARCH}/file.txt$\"")
+
+unset(result)
+find_file(result NAMES file.txt 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.txt$\"")
+# VIEW TARGET should have same value as VIEW HOST
+unset(result2)
+find_file(result2 NAMES file.txt 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")
+
+ unset(result)
+ find_file(result NAMES file.txt 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.txt$\"")
+
+ unset(result)
+ find_file(result NAMES file.txt 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.txt$\"")
+
+ unset(result)
+ find_file(result NAMES file.txt 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.txt$\"")
+ unset(result)
+
+ find_file(result NAMES file.txt 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.txt$\"")
+
+ # check the second view is taken into account
+ unset(result)
+ find_file(result NAMES file32bit.txt 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.txt$\"")
+
+ unset(result)
+ find_file(result NAMES file64bit.txt 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.txt$\"")
+
+ # check the both views are taken into account
+ unset(result)
+ find_file(result NAMES file32bit.txt 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.txt$\"")
+
+ unset(result)
+ find_file(result NAMES file64bit.txt 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.txt$\"")
+
+else() # 32bit
+
+ # no 64bit registry: file not found
+ unset(result)
+ find_file(result NAMES file.txt 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_file(result NAMES file.txt 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.txt$\"")
+
+ # views 64_32 and 32_64 give same result
+ unset(result)
+ find_file(result NAMES file.txt 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.txt$\"")
+
+ unset(result)
+ find_file(result NAMES file.txt 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.txt$\"")
+
+ # check the both views are usable on 32bit platforms
+ unset(result)
+ find_file(result NAMES file.txt 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.txt$\"")
+
+endif()
+
+# HKCU/Software/Classes/CLSID/CMake-Tests/find_file: Query specific value
+set(FILE_DIR "[{|}HKCU/Software/Classes/CLSID/CMake-Tests/find_file|FILE_DIR]")
+set(FILE_DIR2 "[HKCU\\Software\\Classes\\CLSID\\CMake-Tests\\find_file;FILE_DIR]")
+
+unset(result)
+find_file(result NAMES file.txt HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REQUIRED NO_CACHE NO_DEFAULT_PATH)
+check("${FILE_DIR}" "${result}" "result MATCHES \"/${ARCH}/file.txt$\"")
+
+# query value using special name should be identical to default value
+unset(result)
+find_file(result NAMES file.txt HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR2}" REQUIRED NO_CACHE NO_DEFAULT_PATH)
+check("${FILE_DIR2}" "${result}" "result MATCHES \"/${ARCH}/file.txt$\"")
+
+unset(result)
+find_file(result NAMES file.txt HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW HOST REQUIRED NO_CACHE NO_DEFAULT_PATH)
+check("${FILE_DIR}" "${result}" "result MATCHES \"/${ARCH}/file.txt$\"")
+# VIEW TARGET should have same value as VIEW HOST
+unset(result2)
+find_file(result2 NAMES file.txt HINTS "${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")
+
+ unset(result)
+ find_file(result NAMES file.txt HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64 REQUIRED NO_CACHE NO_DEFAULT_PATH)
+ check("${FILE_DIR}" "${result}" "result MATCHES \"/64bit/file.txt$\"")
+
+ unset(result)
+ find_file(result NAMES file.txt HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32 REQUIRED NO_CACHE NO_DEFAULT_PATH)
+ check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/file.txt$\"")
+
+ unset(result)
+ find_file(result NAMES file.txt HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64_32 REQUIRED NO_CACHE NO_DEFAULT_PATH)
+ check("${FILE_DIR}" "${result}" "result MATCHES \"/64bit/file.txt$\"")
+ unset(result)
+
+ find_file(result NAMES file.txt HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32_64 REQUIRED NO_CACHE NO_DEFAULT_PATH)
+ check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/file.txt$\"")
+
+ # check the second view is taken into account
+ unset(result)
+ find_file(result NAMES file32bit.txt HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64_32 REQUIRED NO_CACHE NO_DEFAULT_PATH)
+ check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/file32bit.txt$\"")
+
+ unset(result)
+ find_file(result NAMES file64bit.txt HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32_64 NO_CACHE NO_DEFAULT_PATH)
+ check("${FILE_DIR}" "${result}" "result MATCHES \"/64bit/file64bit.txt$\"")
+
+ # check the both views are taken into account
+ unset(result)
+ find_file(result NAMES file32bit.txt HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW BOTH REQUIRED NO_CACHE NO_DEFAULT_PATH)
+ check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/file32bit.txt$\"")
+
+ unset(result)
+ find_file(result NAMES file64bit.txt HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW BOTH REQUIRED NO_CACHE NO_DEFAULT_PATH)
+ check("${FILE_DIR}" "${result}" "result MATCHES \"/64bit/file64bit.txt$\"")
+
+else() # 32bit
+
+ # no 64bit registry: file not found
+ unset(result)
+ find_file(result NAMES file.txt HINTS "${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_file(result NAMES file.txt HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32 REQUIRED NO_CACHE NO_DEFAULT_PATH)
+ check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/file.txt$\"")
+
+ unset(result)
+ find_file(result NAMES file.txt HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64_32 REQUIRED NO_CACHE NO_DEFAULT_PATH)
+ check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/file.txt$\"")
+
+ unset(result)
+ find_file(result NAMES file.txt HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32_64 REQUIRED NO_CACHE NO_DEFAULT_PATH)
+ check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/file.txt$\"")
+
+ # check the both views are taken into account
+ unset(result)
+ find_file(result NAMES file.txt HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW BOTH REQUIRED NO_CACHE NO_DEFAULT_PATH)
+ check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/file.txt$\"")
+
+endif()
+
+if (ARCH STREQUAL "64bit")
+
+ # Check influence of variable CMAKE_SIZEOF_VOID_P
+ set(CMAKE_SIZEOF_VOID_P 8)
+ unset(result)
+ find_file(result NAMES file.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW TARGET REQUIRED NO_CACHE NO_DEFAULT_PATH)
+ check("${FILE_DIR}" "${result}" "result MATCHES \"/64bit/file.txt$\"")
+
+ unset(result)
+ find_file(result NAMES file.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW HOST REQUIRED NO_CACHE NO_DEFAULT_PATH)
+ check("${FILE_DIR}" "${result}" "result MATCHES \"/${ARCH}/file.txt$\"")
+
+
+ set(CMAKE_SIZEOF_VOID_P 4)
+ unset(result)
+ find_file(result NAMES file.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW TARGET REQUIRED NO_CACHE NO_DEFAULT_PATH)
+ check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/file.txt$\"")
+
+ unset(result)
+ find_file(result NAMES file.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW HOST REQUIRED NO_CACHE NO_DEFAULT_PATH)
+ check("${FILE_DIR}" "${result}" "result MATCHES \"/${ARCH}/file.txt$\"")
+
+ 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_file(result NAMES file.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REQUIRED NO_CACHE NO_DEFAULT_PATH)
+ check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/file.txt$\"")
+
+ cmake_policy(SET CMP0134 NEW)
+ # CMAKE_SIZEOF_VOID_P is not set, so search first the HOST architecture registry
+ unset(result)
+ find_file(result NAMES file.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REQUIRED NO_CACHE NO_DEFAULT_PATH)
+ check("${FILE_DIR}" "${result}" "result MATCHES \"/${ARCH}/file.txt$\"")
+
+endif()
diff --git a/Tests/RunCMake/find_file/RunCMakeTest.cmake b/Tests/RunCMake/find_file/RunCMakeTest.cmake
index c5cd5fa..23765d4 100644
--- a/Tests/RunCMake/find_file/RunCMakeTest.cmake
+++ b/Tests/RunCMake/find_file/RunCMakeTest.cmake
@@ -5,5 +5,33 @@ run_cmake(FromPrefixPath)
run_cmake(PrefixInPATH)
run_cmake(Required)
run_cmake(NO_CACHE)
+run_cmake(REGISTRY_VIEW-no-view)
+run_cmake(REGISTRY_VIEW-wrong-view)
run_cmake_with_options(FromPATHEnvDebugVar --debug-find-var=PrefixInPATH_File)
+
+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_file" /f OUTPUT_QUIET ERROR_QUIET)
+ if (ARCH STREQUAL "64bit")
+ execute_process(COMMAND "${REG}" delete "HKCU\\SOFTWARE\\Classes\\WOW6432Node\\CLSID\\CMake-Tests\\find_file" /f OUTPUT_QUIET ERROR_QUIET)
+ endif()
+ endif()
+endif()
diff --git a/Tests/RunCMake/find_file/default.32bit/file.txt b/Tests/RunCMake/find_file/default.32bit/file.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/find_file/default.32bit/file.txt
diff --git a/Tests/RunCMake/find_file/default.32bit/file32bit.txt b/Tests/RunCMake/find_file/default.32bit/file32bit.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/find_file/default.32bit/file32bit.txt
diff --git a/Tests/RunCMake/find_file/default.64bit/file.txt b/Tests/RunCMake/find_file/default.64bit/file.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/find_file/default.64bit/file.txt
diff --git a/Tests/RunCMake/find_file/default.64bit/file64bit.txt b/Tests/RunCMake/find_file/default.64bit/file64bit.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/find_file/default.64bit/file64bit.txt
diff --git a/Tests/RunCMake/find_file/registry_host32bit.reg b/Tests/RunCMake/find_file/registry_host32bit.reg
new file mode 100644
index 0000000..2987185
--- /dev/null
+++ b/Tests/RunCMake/find_file/registry_host32bit.reg
Binary files differ
diff --git a/Tests/RunCMake/find_file/registry_host64bit.reg b/Tests/RunCMake/find_file/registry_host64bit.reg
new file mode 100644
index 0000000..2d70fa9
--- /dev/null
+++ b/Tests/RunCMake/find_file/registry_host64bit.reg
Binary files differ
diff --git a/Tests/RunCMake/find_library/32bit/file.lib b/Tests/RunCMake/find_library/32bit/file.lib
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/find_library/32bit/file.lib
diff --git a/Tests/RunCMake/find_library/32bit/file32bit.lib b/Tests/RunCMake/find_library/32bit/file32bit.lib
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/find_library/32bit/file32bit.lib
diff --git a/Tests/RunCMake/find_library/64bit/file.lib b/Tests/RunCMake/find_library/64bit/file.lib
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/find_library/64bit/file.lib
diff --git a/Tests/RunCMake/find_library/64bit/file64bit.lib b/Tests/RunCMake/find_library/64bit/file64bit.lib
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/find_library/64bit/file64bit.lib
diff --git a/Tests/RunCMake/find_library/REGISTRY_VIEW-no-view-result.txt b/Tests/RunCMake/find_library/REGISTRY_VIEW-no-view-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/find_library/REGISTRY_VIEW-no-view-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/find_library/REGISTRY_VIEW-no-view-stderr.txt b/Tests/RunCMake/find_library/REGISTRY_VIEW-no-view-stderr.txt
new file mode 100644
index 0000000..ec1877c
--- /dev/null
+++ b/Tests/RunCMake/find_library/REGISTRY_VIEW-no-view-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at REGISTRY_VIEW-no-view.cmake:[0-9]+ \(find_library\):
+ find_library missing required argument for "REGISTRY_VIEW"
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/find_library/REGISTRY_VIEW-no-view.cmake b/Tests/RunCMake/find_library/REGISTRY_VIEW-no-view.cmake
new file mode 100644
index 0000000..e87a6c3
--- /dev/null
+++ b/Tests/RunCMake/find_library/REGISTRY_VIEW-no-view.cmake
@@ -0,0 +1,2 @@
+
+find_library(result NAMES input.txt REGISTRY_VIEW)
diff --git a/Tests/RunCMake/find_library/REGISTRY_VIEW-wrong-view-result.txt b/Tests/RunCMake/find_library/REGISTRY_VIEW-wrong-view-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/find_library/REGISTRY_VIEW-wrong-view-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/find_library/REGISTRY_VIEW-wrong-view-stderr.txt b/Tests/RunCMake/find_library/REGISTRY_VIEW-wrong-view-stderr.txt
new file mode 100644
index 0000000..3e7f814
--- /dev/null
+++ b/Tests/RunCMake/find_library/REGISTRY_VIEW-wrong-view-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at REGISTRY_VIEW-wrong-view.cmake:[0-9]+ \(find_library\):
+ find_library 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_library/REGISTRY_VIEW-wrong-view.cmake b/Tests/RunCMake/find_library/REGISTRY_VIEW-wrong-view.cmake
new file mode 100644
index 0000000..e4a636a
--- /dev/null
+++ b/Tests/RunCMake/find_library/REGISTRY_VIEW-wrong-view.cmake
@@ -0,0 +1,2 @@
+
+find_library(result NAMES input.txt REGISTRY_VIEW WRONG_VIEW)
diff --git a/Tests/RunCMake/find_library/Registry-query.cmake b/Tests/RunCMake/find_library/Registry-query.cmake
new file mode 100644
index 0000000..22968aa
--- /dev/null
+++ b/Tests/RunCMake/find_library/Registry-query.cmake
@@ -0,0 +1,218 @@
+
+# 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_library: Query default value
+set(FILE_DIR "[HKCU/Software/Classes/CLSID/CMake-Tests/find_library]")
+set(FILE_DIR2 "[HKCU/Software/Classes/CLSID/CMake-Tests/find_library;(default)]")
+
+unset(result)
+find_library(result NAMES file.lib PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REQUIRED NO_CACHE NO_DEFAULT_PATH)
+check("${FILE_DIR}" "${result}" "result MATCHES \"default.${ARCH}/file.lib$\"")
+
+# query value using special name should be identical to default value
+unset(result)
+find_library(result NAMES file.lib PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR2}" REQUIRED NO_CACHE NO_DEFAULT_PATH)
+check("${FILE_DIR2}" "${result}" "result MATCHES \"default.${ARCH}/file.lib$\"")
+
+unset(result)
+find_library(result NAMES file.lib 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.lib$\"")
+# VIEW TARGET should have same value as VIEW HOST
+unset(result2)
+find_library(result2 NAMES file.lib 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")
+
+ unset(result)
+ find_library(result NAMES file.lib 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.lib$\"")
+
+ unset(result)
+ find_library(result NAMES file.lib 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.lib$\"")
+
+ unset(result)
+ find_library(result NAMES file.lib 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.lib$\"")
+
+ unset(result)
+ find_library(result NAMES file.lib 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.lib$\"")
+
+ # check the second view is taken into account
+ unset(result)
+ find_library(result NAMES file32bit.lib 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.lib$\"")
+
+ unset(result)
+ find_library(result NAMES file64bit.lib 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.lib$\"")
+ unset(result)
+
+ # check the both views are taken into account
+ unset(result)
+ find_library(result NAMES file32bit.lib 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.lib$\"")
+
+ unset(result)
+ find_library(result NAMES file64bit.lib 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.lib$\"")
+ unset(result)
+
+else() # 32bit
+
+ # no 64bit registry: file not found
+ unset(result)
+ find_library(result NAMES file.lib 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_library(result NAMES file.lib 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.lib$\"")
+
+ # views 64_32 and 32_64 give same result
+ unset(result)
+ find_library(result NAMES file.lib 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.lib$\"")
+
+ unset(result)
+ find_library(result NAMES file.lib 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.lib$\"")
+
+ # check the both views are usable on 32bit platforms
+ unset(result)
+ find_library(result NAMES file.lib 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.lib$\"")
+
+endif()
+
+# HKCU/Software/Classes/CLSID/CMake-Tests/find_library: Query specific value
+set(FILE_DIR "[{|}HKCU/Software/Classes/CLSID/CMake-Tests/find_library|FILE_DIR]")
+set(FILE_DIR2 "[HKCU\\Software\\Classes\\CLSID\\CMake-Tests\\find_library;FILE_DIR]")
+
+unset(result)
+find_library(result NAMES file.lib HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REQUIRED NO_CACHE NO_DEFAULT_PATH)
+check("${FILE_DIR}" "${result}" "result MATCHES \"/${ARCH}/file.lib$\"")
+
+# query value using special name should be identical to default value
+unset(result)
+find_library(result NAMES file.lib HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR2}" REQUIRED NO_CACHE NO_DEFAULT_PATH)
+check("${FILE_DIR2}" "${result}" "result MATCHES \"/${ARCH}/file.lib$\"")
+
+unset(result)
+find_library(result NAMES file.lib HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW HOST REQUIRED NO_CACHE NO_DEFAULT_PATH)
+check("${FILE_DIR}" "${result}" "result MATCHES \"/${ARCH}/file.lib$\"")
+# VIEW TARGET should have same value as VIEW HOST
+unset(result2)
+find_library(result2 NAMES file.lib HINTS "${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")
+
+ unset(result)
+ find_library(result NAMES file.lib HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64 REQUIRED NO_CACHE NO_DEFAULT_PATH)
+ check("${FILE_DIR}" "${result}" "result MATCHES \"/64bit/file.lib$\"")
+
+ unset(result)
+ find_library(result NAMES file.lib HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32 REQUIRED NO_CACHE NO_DEFAULT_PATH)
+ check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/file.lib$\"")
+
+ unset(result)
+ find_library(result NAMES file.lib HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64_32 REQUIRED NO_CACHE NO_DEFAULT_PATH)
+ check("${FILE_DIR}" "${result}" "result MATCHES \"/64bit/file.lib$\"")
+
+ unset(result)
+ find_library(result NAMES file.lib HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32_64 REQUIRED NO_CACHE NO_DEFAULT_PATH)
+ check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/file.lib$\"")
+
+ # check the second view is taken into account
+ unset(result)
+ find_library(result NAMES file32bit.lib HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64_32 REQUIRED NO_CACHE NO_DEFAULT_PATH)
+ check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/file32bit.lib$\"")
+
+ unset(result)
+ find_library(result NAMES file64bit.lib HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32_64 REQUIRED NO_CACHE NO_DEFAULT_PATH)
+ check("${FILE_DIR}" "${result}" "result MATCHES \"/64bit/file64bit.lib$\"")
+
+ # check the both views are taken into account
+ unset(result)
+ find_library(result NAMES file32bit.lib HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW BOTH NO_CACHE NO_DEFAULT_PATH)
+ check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/file32bit.lib$\"")
+
+ unset(result)
+ find_library(result NAMES file64bit.lib HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW BOTH REQUIRED NO_CACHE NO_DEFAULT_PATH)
+ check("${FILE_DIR}" "${result}" "result MATCHES \"/64bit/file64bit.lib$\"")
+
+else() # 32bit
+
+ # no 64bit registry: file not found
+ unset(result)
+ find_library(result NAMES file.lib HINTS "${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_library(result NAMES file.lib HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32 REQUIRED NO_CACHE NO_DEFAULT_PATH)
+ check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/file.lib$\"")
+
+ unset(result)
+ find_library(result NAMES file.lib HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64_32 REQUIRED NO_CACHE NO_DEFAULT_PATH)
+ check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/file.lib$\"")
+
+ unset(result)
+ find_library(result NAMES file.lib HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32_64 REQUIRED NO_CACHE NO_DEFAULT_PATH)
+ check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/file.lib$\"")
+
+ unset(result)
+ find_library(result NAMES file.lib HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW BOTH REQUIRED NO_CACHE NO_DEFAULT_PATH)
+ check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/file.lib$\"")
+
+endif()
+
+if (ARCH STREQUAL "64bit")
+
+ # Check influence of variable CMAKE_SIZEOF_VOID_P
+ set(CMAKE_SIZEOF_VOID_P 8)
+ unset(result)
+ find_library(result NAMES file.lib PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW TARGET REQUIRED NO_CACHE NO_DEFAULT_PATH)
+ check("${FILE_DIR}" "${result}" "result MATCHES \"/64bit/file.lib$\"")
+
+ unset(result)
+ find_library(result NAMES file.lib PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW HOST REQUIRED NO_CACHE NO_DEFAULT_PATH)
+ check("${FILE_DIR}" "${result}" "result MATCHES \"/${ARCH}/file.lib$\"")
+
+
+ set(CMAKE_SIZEOF_VOID_P 4)
+ unset(result)
+ find_library(result NAMES file.lib PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW TARGET REQUIRED NO_CACHE NO_DEFAULT_PATH)
+ check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/file.lib$\"")
+
+ unset(result)
+ find_library(result NAMES file.lib PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW HOST REQUIRED NO_CACHE NO_DEFAULT_PATH)
+ check("${FILE_DIR}" "${result}" "result MATCHES \"/${ARCH}/file.lib$\"")
+
+ 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_library(result NAMES file.lib PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REQUIRED NO_CACHE NO_DEFAULT_PATH)
+ check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/file.lib$\"")
+
+ cmake_policy(SET CMP0134 NEW)
+ # CMAKE_SIZEOF_VOID_P is not set, so search first the HOST architecture registry
+ unset(result)
+ find_library(result NAMES file.lib PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REQUIRED NO_CACHE NO_DEFAULT_PATH)
+ check("${FILE_DIR}" "${result}" "result MATCHES \"/${ARCH}/file.lib$\"")
+
+endif()
diff --git a/Tests/RunCMake/find_library/RunCMakeTest.cmake b/Tests/RunCMake/find_library/RunCMakeTest.cmake
index ef1ede6..de0ee14 100644
--- a/Tests/RunCMake/find_library/RunCMakeTest.cmake
+++ b/Tests/RunCMake/find_library/RunCMakeTest.cmake
@@ -11,7 +11,35 @@ endif()
run_cmake(PrefixInPATH)
run_cmake(Required)
run_cmake(NO_CACHE)
+run_cmake(REGISTRY_VIEW-no-view)
+run_cmake(REGISTRY_VIEW-wrong-view)
run_cmake_script(FromScriptMode "-DTEMP_DIR=${RunCMake_BINARY_DIR}/FromScriptMode-temp")
run_cmake_with_options(FromPATHEnvDebugVar --debug-find-var=CREATED_LIBRARY)
+
+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_library" /f OUTPUT_QUIET ERROR_QUIET)
+ if (ARCH STREQUAL "64bit")
+ execute_process(COMMAND "${REG}" delete "HKCU\\SOFTWARE\\Classes\\WOW6432Node\\CLSID\\CMake-Tests\\find_library" /f OUTPUT_QUIET ERROR_QUIET)
+ endif()
+ endif()
+endif()
diff --git a/Tests/RunCMake/find_library/default.32bit/file.lib b/Tests/RunCMake/find_library/default.32bit/file.lib
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/find_library/default.32bit/file.lib
diff --git a/Tests/RunCMake/find_library/default.32bit/file32bit.lib b/Tests/RunCMake/find_library/default.32bit/file32bit.lib
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/find_library/default.32bit/file32bit.lib
diff --git a/Tests/RunCMake/find_library/default.64bit/file.lib b/Tests/RunCMake/find_library/default.64bit/file.lib
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/find_library/default.64bit/file.lib
diff --git a/Tests/RunCMake/find_library/default.64bit/file64bit.lib b/Tests/RunCMake/find_library/default.64bit/file64bit.lib
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/find_library/default.64bit/file64bit.lib
diff --git a/Tests/RunCMake/find_library/registry_host32bit.reg b/Tests/RunCMake/find_library/registry_host32bit.reg
new file mode 100644
index 0000000..cf36b34
--- /dev/null
+++ b/Tests/RunCMake/find_library/registry_host32bit.reg
Binary files differ
diff --git a/Tests/RunCMake/find_library/registry_host64bit.reg b/Tests/RunCMake/find_library/registry_host64bit.reg
new file mode 100644
index 0000000..8a87c98
--- /dev/null
+++ b/Tests/RunCMake/find_library/registry_host64bit.reg
Binary files differ
diff --git a/Tests/RunCMake/find_package/32bit/RegistryView32Config.cmake b/Tests/RunCMake/find_package/32bit/RegistryView32Config.cmake
new file mode 100644
index 0000000..63f9622
--- /dev/null
+++ b/Tests/RunCMake/find_package/32bit/RegistryView32Config.cmake
@@ -0,0 +1,4 @@
+
+if (NOT EXPECTED_LOCATION STREQUAL "32bit")
+ message (SEND_ERROR "RegistryViewConfig: location is '32bit' but expects '${EXPECTED_LOCATION}'")
+endif()
diff --git a/Tests/RunCMake/find_package/32bit/RegistryViewConfig.cmake b/Tests/RunCMake/find_package/32bit/RegistryViewConfig.cmake
new file mode 100644
index 0000000..63f9622
--- /dev/null
+++ b/Tests/RunCMake/find_package/32bit/RegistryViewConfig.cmake
@@ -0,0 +1,4 @@
+
+if (NOT EXPECTED_LOCATION STREQUAL "32bit")
+ message (SEND_ERROR "RegistryViewConfig: location is '32bit' but expects '${EXPECTED_LOCATION}'")
+endif()
diff --git a/Tests/RunCMake/find_package/64bit/RegistryView64Config.cmake b/Tests/RunCMake/find_package/64bit/RegistryView64Config.cmake
new file mode 100644
index 0000000..3d64301
--- /dev/null
+++ b/Tests/RunCMake/find_package/64bit/RegistryView64Config.cmake
@@ -0,0 +1,4 @@
+
+if (NOT EXPECTED_LOCATION STREQUAL "64bit")
+ message (SEND_ERROR "RegistryViewConfig: location is '64bit' but expects '${EXPECTED_LOCATION}'")
+endif()
diff --git a/Tests/RunCMake/find_package/64bit/RegistryViewConfig.cmake b/Tests/RunCMake/find_package/64bit/RegistryViewConfig.cmake
new file mode 100644
index 0000000..3d64301
--- /dev/null
+++ b/Tests/RunCMake/find_package/64bit/RegistryViewConfig.cmake
@@ -0,0 +1,4 @@
+
+if (NOT EXPECTED_LOCATION STREQUAL "64bit")
+ message (SEND_ERROR "RegistryViewConfig: location is '64bit' but expects '${EXPECTED_LOCATION}'")
+endif()
diff --git a/Tests/RunCMake/find_package/FindRegistryView.cmake b/Tests/RunCMake/find_package/FindRegistryView.cmake
new file mode 100644
index 0000000..e4080a6
--- /dev/null
+++ b/Tests/RunCMake/find_package/FindRegistryView.cmake
@@ -0,0 +1,11 @@
+
+if (EXPECTED_REGISTRY_VIEW STREQUAL "UNDEFINED")
+ if (DEFINED ${CMAKE_FIND_PACKAGE_NAME}_FIND_REGISTRY_VIEW)
+ message(SEND_ERROR "${CMAKE_FIND_PACKAGE_NAME}_FIND_REGISTRY_VIEW: unexpectedly defined as '${${CMAKE_FIND_PACKAGE_NAME}_FIND_REGISTRY_VIEW}' instead of '${EXPECTED_REGISTRY_VIEW}'")
+ endif()
+ return()
+endif()
+
+if (NOT ${CMAKE_FIND_PACKAGE_NAME}_FIND_REGISTRY_VIEW STREQUAL EXPECTED_REGISTRY_VIEW)
+ message(SEND_ERROR "${CMAKE_FIND_PACKAGE_NAME}_FIND_REGISTRY_VIEW: '${${CMAKE_FIND_PACKAGE_NAME}_FIND_REGISTRY_VIEW}' instead of '${EXPECTED_REGISTRY_VIEW}'")
+endif()
diff --git a/Tests/RunCMake/find_package/REGISTRY_VIEW-no-view-result.txt b/Tests/RunCMake/find_package/REGISTRY_VIEW-no-view-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/find_package/REGISTRY_VIEW-no-view-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/find_package/REGISTRY_VIEW-no-view-stderr.txt b/Tests/RunCMake/find_package/REGISTRY_VIEW-no-view-stderr.txt
new file mode 100644
index 0000000..9dbcc93
--- /dev/null
+++ b/Tests/RunCMake/find_package/REGISTRY_VIEW-no-view-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at REGISTRY_VIEW-no-view.cmake:[0-9]+ \(find_package\):
+ find_package missing required argument for "REGISTRY_VIEW"
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/find_package/REGISTRY_VIEW-no-view.cmake b/Tests/RunCMake/find_package/REGISTRY_VIEW-no-view.cmake
new file mode 100644
index 0000000..866cc54
--- /dev/null
+++ b/Tests/RunCMake/find_package/REGISTRY_VIEW-no-view.cmake
@@ -0,0 +1,2 @@
+
+find_package(result NAMES input.txt REGISTRY_VIEW)
diff --git a/Tests/RunCMake/find_package/REGISTRY_VIEW-propagated.cmake b/Tests/RunCMake/find_package/REGISTRY_VIEW-propagated.cmake
new file mode 100644
index 0000000..8d8fec7
--- /dev/null
+++ b/Tests/RunCMake/find_package/REGISTRY_VIEW-propagated.cmake
@@ -0,0 +1,16 @@
+
+set (CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}")
+
+# when REGISTRY_VIEW is not specified, should not be defined in module
+set (EXPECTED_REGISTRY_VIEW "UNDEFINED")
+find_package(RegistryView)
+
+# query package to check if variable is propagated correctly
+set(EXPECTED_REGISTRY_VIEW "TARGET")
+find_package(RegistryView REGISTRY_VIEW TARGET)
+
+set(EXPECTED_REGISTRY_VIEW "64_32")
+find_package(RegistryView REGISTRY_VIEW 64_32)
+
+set(EXPECTED_REGISTRY_VIEW "32")
+find_package(RegistryView REGISTRY_VIEW 32)
diff --git a/Tests/RunCMake/find_package/REGISTRY_VIEW-wrong-view-result.txt b/Tests/RunCMake/find_package/REGISTRY_VIEW-wrong-view-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/find_package/REGISTRY_VIEW-wrong-view-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/find_package/REGISTRY_VIEW-wrong-view-stderr.txt b/Tests/RunCMake/find_package/REGISTRY_VIEW-wrong-view-stderr.txt
new file mode 100644
index 0000000..e65af62
--- /dev/null
+++ b/Tests/RunCMake/find_package/REGISTRY_VIEW-wrong-view-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at REGISTRY_VIEW-wrong-view.cmake:[0-9]+ \(find_package\):
+ find_package 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_package/REGISTRY_VIEW-wrong-view.cmake b/Tests/RunCMake/find_package/REGISTRY_VIEW-wrong-view.cmake
new file mode 100644
index 0000000..e2aff3cf
--- /dev/null
+++ b/Tests/RunCMake/find_package/REGISTRY_VIEW-wrong-view.cmake
@@ -0,0 +1,2 @@
+
+find_package(result NAMES input.txt REGISTRY_VIEW WRONG_VIEW)
diff --git a/Tests/RunCMake/find_package/Registry-query.cmake b/Tests/RunCMake/find_package/Registry-query.cmake
new file mode 100644
index 0000000..181c479
--- /dev/null
+++ b/Tests/RunCMake/find_package/Registry-query.cmake
@@ -0,0 +1,216 @@
+
+# helper macro for test clean-up
+macro(CLEAN)
+ unset(RegistryView_DIR CACHE)
+ unset(RegistryView_FOUND)
+ unset(RegistryView64_DIR CACHE)
+ unset(RegistryView64_FOUND)
+ unset(RegistryView32_DIR CACHE)
+ unset(RegistryView32_FOUND)
+endmacro()
+
+
+cmake_policy(SET CMP0134 NEW)
+
+# HKCU/Software/Classes/CLSID/CMake-Tests/find_package: Query default value
+set(FILE_DIR "[HKCU/Software/Classes/CLSID/CMake-Tests/find_package]")
+set(FILE_DIR2 "[HKCU/Software/Classes/CLSID/CMake-Tests/find_package;(default)]")
+
+set(EXPECTED_LOCATION "default.${ARCH}")
+
+find_package(RegistryView PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REQUIRED NO_DEFAULT_PATH)
+clean()
+
+# query value using special name should be identical to default value
+find_package(RegistryView PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR2}" REQUIRED NO_DEFAULT_PATH)
+clean()
+
+find_package(RegistryView PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW HOST REQUIRED NO_DEFAULT_PATH)
+clean()
+
+# VIEW TARGET should have same value as VIEW HOST
+find_package(RegistryView PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW TARGET REQUIRED NO_DEFAULT_PATH)
+clean()
+
+if (ARCH STREQUAL "64bit")
+
+ set(EXPECTED_LOCATION "default.64bit")
+ find_package(RegistryView PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64 REQUIRED NO_DEFAULT_PATH)
+ clean()
+
+ set(EXPECTED_LOCATION "default.32bit")
+ find_package(RegistryView PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32 REQUIRED NO_DEFAULT_PATH)
+ clean()
+
+ set(EXPECTED_LOCATION "default.64bit")
+ find_package(RegistryView PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64_32 REQUIRED NO_DEFAULT_PATH)
+ clean()
+
+ set(EXPECTED_LOCATION "default.32bit")
+ find_package(RegistryView PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32_64 REQUIRED NO_DEFAULT_PATH)
+ clean()
+
+ # check the second view is taken into account
+ set(EXPECTED_LOCATION "default.32bit")
+ find_package(RegistryView32 PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64_32 REQUIRED NO_DEFAULT_PATH)
+ clean()
+
+ set(EXPECTED_LOCATION "default.64bit")
+ find_package(RegistryView64 PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32_64 REQUIRED NO_DEFAULT_PATH)
+ clean()
+
+ # check the both views are taken into account
+ set(EXPECTED_LOCATION "default.32bit")
+ find_package(RegistryView32 PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW BOTH REQUIRED NO_DEFAULT_PATH)
+ clean()
+
+ set(EXPECTED_LOCATION "default.64bit")
+ find_package(RegistryView64 PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW BOTH REQUIRED NO_DEFAULT_PATH)
+ clean()
+
+else() # 32bit
+
+ # no 64bit registry: file not found
+ find_package(RegistryView PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64 NO_DEFAULT_PATH)
+ if (RegistryView_FOUND)
+ message (SEND_ERROR "Unexpectedly found file '${RegistryView_DIR}/RegistryViewConfog.cmake'")
+ endif()
+ clean()
+
+ set(EXPECTED_LOCATION "default.32bit")
+
+ find_package(RegistryView PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32 REQUIRED NO_DEFAULT_PATH)
+ clean()
+
+ # views 64_32 and 32_64 give same result
+ find_package(RegistryView PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64_32 REQUIRED NO_DEFAULT_PATH)
+ clean()
+
+ find_package(RegistryView PATHS "${CMAKE_ CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32_64 REQUIRED NO_DEFAULT_PATH)
+ clean()
+
+ # check the both views are usable on 32bit platforms
+ find_package(RegistryView PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW BOTH REQUIRED NO_DEFAULT_PATH)
+ clean()
+
+endif()
+
+
+# HKCU/Software/Classes/CLSID/CMake-Tests/find_package: Query specific value
+set(FILE_DIR "[{|}HKCU/Software/Classes/CLSID/CMake-Tests/find_package|FILE_DIR]")
+set(FILE_DIR2 "[HKCU\\Software\\Classes\\CLSID\\CMake-Tests\\find_package;FILE_DIR]")
+
+set(EXPECTED_LOCATION "${ARCH}")
+
+find_package(RegistryView HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REQUIRED NO_DEFAULT_PATH)
+clean()
+
+# query value using special name should be identical to default value
+find_package(RegistryView HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR2}" REQUIRED NO_DEFAULT_PATH)
+clean()
+
+find_package(RegistryView HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW HOST REQUIRED NO_DEFAULT_PATH)
+clean()
+# VIEW TARGET should have same value as VIEW HOST
+find_package(RegistryView HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW TARGET REQUIRED NO_DEFAULT_PATH)
+clean()
+
+if (ARCH STREQUAL "64bit")
+
+ set(EXPECTED_LOCATION "64bit")
+ find_package(RegistryView HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64 REQUIRED NO_DEFAULT_PATH)
+ clean()
+
+ set(EXPECTED_LOCATION "32bit")
+ find_package(RegistryView HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32 REQUIRED NO_DEFAULT_PATH)
+ clean()
+
+ set(EXPECTED_LOCATION "64bit")
+ find_package(RegistryView HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64_32 REQUIRED NO_DEFAULT_PATH)
+ clean()
+
+ set(EXPECTED_LOCATION "32bit")
+ find_package(RegistryView HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32_64 REQUIRED NO_DEFAULT_PATH)
+ clean()
+
+ # check the second view is taken into account
+ find_package(RegistryView32 HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64_32 REQUIRED NO_DEFAULT_PATH)
+ clean()
+
+ set(EXPECTED_LOCATION "64bit")
+ find_package(RegistryView64 HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32_64 REQUIRED NO_DEFAULT_PATH)
+ clean()
+
+ # check the both views are taken into account
+ set(EXPECTED_LOCATION "32bit")
+ find_package(RegistryView32 HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW BOTH REQUIRED NO_DEFAULT_PATH)
+ clean()
+
+ set(EXPECTED_LOCATION "64bit")
+ find_package(RegistryView64 NAMES HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW BOTH REQUIRED NO_DEFAULT_PATH)
+ clean()
+
+else() # 32bit
+
+ # no 64bit registry: file not found
+ find_package(RegistryView HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64 NO_DEFAULT_PATH)
+ if (RegistryView_FOUND)
+ message (SEND_ERROR "Unexpectedly found file '${RegistryView_DIR}/RegistryViewConfog.cmake'")
+ endif()
+ clean()
+
+ set(EXPECTED_LOCATION "32bit")
+
+ find_package(RegistryView HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32 REQUIRED NO_DEFAULT_PATH)
+ clean()
+
+ find_package(RegistryView HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64_32 REQUIRED NO_DEFAULT_PATH)
+ clean()
+
+ find_package(RegistryView HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32_64 REQUIRED NO_DEFAULT_PATH)
+ clean()
+
+ # check the both views are taken into account
+ find_package(RegistryView HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW BOTH REQUIRED NO_DEFAULT_PATH)
+ clean()
+
+endif()
+
+if (ARCH STREQUAL "64bit")
+
+ # Check influence of variable CMAKE_SIZEOF_VOID_P
+ set(CMAKE_SIZEOF_VOID_P 8)
+ set(EXPECTED_LOCATION "64bit")
+ find_package(RegistryView PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW TARGET)
+ clean()
+
+ find_package(RegistryView PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW HOST)
+ clean()
+
+
+ set(CMAKE_SIZEOF_VOID_P 4)
+ set(EXPECTED_LOCATION "32bit")
+ find_package(RegistryView PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW TARGET)
+ clean()
+
+ set(EXPECTED_LOCATION "64bit")
+ find_package(RegistryView PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW HOST)
+ clean()
+
+ 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
+ set(EXPECTED_LOCATION "32bit")
+ find_package(RegistryView PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}")
+ clean()
+
+ cmake_policy(SET CMP0134 NEW)
+ # CMAKE_SIZEOF_VOID_P is not set, so search first the HOST architecture registry
+ set(EXPECTED_LOCATION "64bit")
+ find_package(RegistryView PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}")
+ clean()
+
+endif()
diff --git a/Tests/RunCMake/find_package/RunCMakeTest.cmake b/Tests/RunCMake/find_package/RunCMakeTest.cmake
index b2d1bf6..32e54d5 100644
--- a/Tests/RunCMake/find_package/RunCMakeTest.cmake
+++ b/Tests/RunCMake/find_package/RunCMakeTest.cmake
@@ -51,8 +51,38 @@ run_cmake(VersionRangeConfigStd2)
run_cmake_with_options(IgnoreInstallPrefix "-DCMAKE_INSTALL_PREFIX=${RunCMake_SOURCE_DIR}/PackageRoot/foo/cmake_root")
run_cmake(IgnorePath)
run_cmake(IgnorePrefixPath)
+run_cmake(REGISTRY_VIEW-no-view)
+run_cmake(REGISTRY_VIEW-wrong-view)
+run_cmake(REGISTRY_VIEW-propagated)
+
if(UNIX
AND NOT MSYS # FIXME: This works on CYGWIN but not on MSYS
)
run_cmake(SetFoundResolved)
endif()
+
+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_package" /f OUTPUT_QUIET ERROR_QUIET)
+ if (ARCH STREQUAL "64bit")
+ execute_process(COMMAND "${REG}" delete "HKCU\\SOFTWARE\\Classes\\WOW6432Node\\CLSID\\CMake-Tests\\find_package" /f OUTPUT_QUIET ERROR_QUIET)
+ endif()
+ endif()
+endif()
diff --git a/Tests/RunCMake/find_package/default.32bit/RegistryView32Config.cmake b/Tests/RunCMake/find_package/default.32bit/RegistryView32Config.cmake
new file mode 100644
index 0000000..8d13254
--- /dev/null
+++ b/Tests/RunCMake/find_package/default.32bit/RegistryView32Config.cmake
@@ -0,0 +1,4 @@
+
+if (NOT EXPECTED_LOCATION STREQUAL "default.32bit")
+ message (SEND_ERROR "RegistryViewConfig: location is 'default.32bit' but expects '${EXPECTED_LOCATION}'")
+endif()
diff --git a/Tests/RunCMake/find_package/default.32bit/RegistryViewConfig.cmake b/Tests/RunCMake/find_package/default.32bit/RegistryViewConfig.cmake
new file mode 100644
index 0000000..8d13254
--- /dev/null
+++ b/Tests/RunCMake/find_package/default.32bit/RegistryViewConfig.cmake
@@ -0,0 +1,4 @@
+
+if (NOT EXPECTED_LOCATION STREQUAL "default.32bit")
+ message (SEND_ERROR "RegistryViewConfig: location is 'default.32bit' but expects '${EXPECTED_LOCATION}'")
+endif()
diff --git a/Tests/RunCMake/find_package/default.64bit/RegistryView64Config.cmake b/Tests/RunCMake/find_package/default.64bit/RegistryView64Config.cmake
new file mode 100644
index 0000000..1d3d78c
--- /dev/null
+++ b/Tests/RunCMake/find_package/default.64bit/RegistryView64Config.cmake
@@ -0,0 +1,4 @@
+
+if (NOT EXPECTED_LOCATION STREQUAL "default.64bit")
+ message (SEND_ERROR "RegistryViewConfig: location is 'default.64bit' but expects '${EXPECTED_LOCATION}'")
+endif()
diff --git a/Tests/RunCMake/find_package/default.64bit/RegistryViewConfig.cmake b/Tests/RunCMake/find_package/default.64bit/RegistryViewConfig.cmake
new file mode 100644
index 0000000..1d3d78c
--- /dev/null
+++ b/Tests/RunCMake/find_package/default.64bit/RegistryViewConfig.cmake
@@ -0,0 +1,4 @@
+
+if (NOT EXPECTED_LOCATION STREQUAL "default.64bit")
+ message (SEND_ERROR "RegistryViewConfig: location is 'default.64bit' but expects '${EXPECTED_LOCATION}'")
+endif()
diff --git a/Tests/RunCMake/find_package/registry_host32bit.reg b/Tests/RunCMake/find_package/registry_host32bit.reg
new file mode 100644
index 0000000..3b2fb50
--- /dev/null
+++ b/Tests/RunCMake/find_package/registry_host32bit.reg
Binary files differ
diff --git a/Tests/RunCMake/find_package/registry_host64bit.reg b/Tests/RunCMake/find_package/registry_host64bit.reg
new file mode 100644
index 0000000..07eb9b7
--- /dev/null
+++ b/Tests/RunCMake/find_package/registry_host64bit.reg
Binary files differ
diff --git a/Tests/RunCMake/find_path/32bit/file.txt b/Tests/RunCMake/find_path/32bit/file.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/find_path/32bit/file.txt
diff --git a/Tests/RunCMake/find_path/32bit/file32bit.txt b/Tests/RunCMake/find_path/32bit/file32bit.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/find_path/32bit/file32bit.txt
diff --git a/Tests/RunCMake/find_path/64bit/file.txt b/Tests/RunCMake/find_path/64bit/file.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/find_path/64bit/file.txt
diff --git a/Tests/RunCMake/find_path/64bit/file64bit.txt b/Tests/RunCMake/find_path/64bit/file64bit.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/find_path/64bit/file64bit.txt
diff --git a/Tests/RunCMake/find_path/REGISTRY_VIEW-no-view-result.txt b/Tests/RunCMake/find_path/REGISTRY_VIEW-no-view-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/find_path/REGISTRY_VIEW-no-view-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/find_path/REGISTRY_VIEW-no-view-stderr.txt b/Tests/RunCMake/find_path/REGISTRY_VIEW-no-view-stderr.txt
new file mode 100644
index 0000000..662d2d3
--- /dev/null
+++ b/Tests/RunCMake/find_path/REGISTRY_VIEW-no-view-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at REGISTRY_VIEW-no-view.cmake:[0-9]+ \(find_path\):
+ find_path missing required argument for "REGISTRY_VIEW"
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/find_path/REGISTRY_VIEW-no-view.cmake b/Tests/RunCMake/find_path/REGISTRY_VIEW-no-view.cmake
new file mode 100644
index 0000000..e76d9dc
--- /dev/null
+++ b/Tests/RunCMake/find_path/REGISTRY_VIEW-no-view.cmake
@@ -0,0 +1,2 @@
+
+find_path(result NAMES input.txt REGISTRY_VIEW)
diff --git a/Tests/RunCMake/find_path/REGISTRY_VIEW-wrong-view-result.txt b/Tests/RunCMake/find_path/REGISTRY_VIEW-wrong-view-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/find_path/REGISTRY_VIEW-wrong-view-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/find_path/REGISTRY_VIEW-wrong-view-stderr.txt b/Tests/RunCMake/find_path/REGISTRY_VIEW-wrong-view-stderr.txt
new file mode 100644
index 0000000..075d6af
--- /dev/null
+++ b/Tests/RunCMake/find_path/REGISTRY_VIEW-wrong-view-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at REGISTRY_VIEW-wrong-view.cmake:[0-9]+ \(find_path\):
+ find_path 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_path/REGISTRY_VIEW-wrong-view.cmake b/Tests/RunCMake/find_path/REGISTRY_VIEW-wrong-view.cmake
new file mode 100644
index 0000000..9f46538
--- /dev/null
+++ b/Tests/RunCMake/find_path/REGISTRY_VIEW-wrong-view.cmake
@@ -0,0 +1,2 @@
+
+find_path(result NAMES input.txt REGISTRY_VIEW WRONG_VIEW)
diff --git a/Tests/RunCMake/find_path/Registry-query.cmake b/Tests/RunCMake/find_path/Registry-query.cmake
new file mode 100644
index 0000000..6d26cd0
--- /dev/null
+++ b/Tests/RunCMake/find_path/Registry-query.cmake
@@ -0,0 +1,218 @@
+
+# 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_path: Query default value
+set(FILE_DIR "[HKCU/Software/Classes/CLSID/CMake-Tests/find_path]")
+set(FILE_DIR2 "[HKCU/Software/Classes/CLSID/CMake-Tests/find_path;(default)]")
+
+unset(result)
+find_path(result NAMES file.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REQUIRED NO_CACHE NO_DEFAULT_PATH)
+check("${FILE_DIR}" "${result}" "result MATCHES \"default.${ARCH}/$\"")
+
+# query value using special name should be identical to default value
+unset(result)
+find_path(result NAMES file.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR2}" REQUIRED NO_CACHE NO_DEFAULT_PATH)
+check("${FILE_DIR2}" "${result}" "result MATCHES \"default.${ARCH}/$\"")
+
+unset(result)
+find_path(result NAMES file.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW HOST REQUIRED NO_CACHE NO_DEFAULT_PATH)
+check("${FILE_DIR}" "${result}" "result MATCHES \"default.${ARCH}/$\"")
+# VIEW TARGET should have same value as VIEW HOST
+unset(result2)
+find_path(result2 NAMES file.txt 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")
+
+ unset(result)
+ find_path(result NAMES file.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64 REQUIRED NO_CACHE NO_DEFAULT_PATH)
+ check("${FILE_DIR}" "${result}" "result MATCHES \"default.64bit/$\"")
+
+ unset(result)
+ find_path(result NAMES file.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32 REQUIRED NO_CACHE NO_DEFAULT_PATH)
+ check("${FILE_DIR}" "${result}" "result MATCHES \"default.32bit/$\"")
+
+ unset(result)
+ find_path(result NAMES file.txt 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/$\"")
+ unset(result)
+
+ find_path(result NAMES file.txt 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/$\"")
+
+ # check the second view is taken into account
+ unset(result)
+ find_path(result NAMES file32bit.txt 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/$\"")
+
+ unset(result)
+ find_path(result NAMES file64bit.txt 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/$\"")
+
+ # check the both views are taken into account
+ unset(result)
+ find_path(result NAMES file32bit.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW BOTH REQUIRED NO_CACHE NO_DEFAULT_PATH)
+ check("${FILE_DIR}" "${result}" "result MATCHES \"default.32bit/$\"")
+
+ unset(result)
+ find_path(result NAMES file64bit.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW BOTH REQUIRED NO_CACHE NO_DEFAULT_PATH)
+ check("${FILE_DIR}" "${result}" "result MATCHES \"default.64bit/$\"")
+
+else() # 32bit
+
+ # no 64bit registry: file not found
+ unset(result)
+ find_path(result NAMES file.txt 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_path(result NAMES file.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32 REQUIRED NO_CACHE NO_DEFAULT_PATH)
+ check("${FILE_DIR}" "${result}" "result MATCHES \"default.32bit/$\"")
+
+ # views 64_32 and 32_64 give same result
+ unset(result)
+ find_path(result NAMES file.txt 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/$\"")
+
+ unset(result)
+ find_path(result NAMES file.txt 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/$\"")
+
+ # check the both views are usable on 32bit platforms
+ unset(result)
+ find_path(result NAMES file.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW BOTH REQUIRED NO_CACHE NO_DEFAULT_PATH)
+ check("${FILE_DIR}" "${result}" "result MATCHES \"default.32bit/$\"")
+
+endif()
+
+
+# HKCU/Software/Classes/CLSID/CMake-Tests/find_path: Query specific value
+set(FILE_DIR "[{|}HKCU/Software/Classes/CLSID/CMake-Tests/find_path|FILE_DIR]")
+set(FILE_DIR2 "[HKCU\\Software\\Classes\\CLSID\\CMake-Tests\\find_path;FILE_DIR]")
+
+unset(result)
+find_path(result NAMES file.txt HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" NO_CACHE REQUIRED NO_DEFAULT_PATH)
+check("${FILE_DIR}" "${result}" "result MATCHES \"/${ARCH}/$\"")
+
+# query value using special name should be identical to default value
+unset(result)
+find_path(result NAMES file.txt HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR2}" NO_CACHE REQUIRED NO_DEFAULT_PATH)
+check("${FILE_DIR2}" "${result}" "result MATCHES \"/${ARCH}/$\"")
+
+unset(result)
+find_path(result NAMES file.txt HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW HOST REQUIRED NO_CACHE NO_DEFAULT_PATH)
+check("${FILE_DIR}" "${result}" "result MATCHES \"/${ARCH}/$\"")
+# VIEW TARGET should have same value as VIEW HOST
+unset(result2)
+find_path(result2 NAMES file.txt HINTS "${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")
+
+unset(result)
+find_path(result NAMES file.txt HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64 REQUIRED NO_CACHE NO_DEFAULT_PATH)
+check("${FILE_DIR}" "${result}" "result MATCHES \"/64bit/$\"")
+
+unset(result)
+find_path(result NAMES file.txt HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32 REQUIRED NO_CACHE NO_DEFAULT_PATH)
+check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/$\"")
+
+unset(result)
+find_path(result NAMES file.txt HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64_32 REQUIRED NO_CACHE NO_DEFAULT_PATH)
+check("${FILE_DIR}" "${result}" "result MATCHES \"/64bit/$\"")
+
+unset(result)
+find_path(result NAMES file.txt HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32_64 REQUIRED NO_CACHE NO_DEFAULT_PATH)
+check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/$\"")
+
+# check the second view is taken into account
+unset(result)
+find_path(result NAMES file32bit.txt HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64_32 REQUIRED NO_CACHE NO_DEFAULT_PATH)
+check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/$\"")
+
+unset(result)
+find_path(result NAMES file64bit.txt HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32_64 REQUIRED NO_CACHE NO_DEFAULT_PATH)
+check("${FILE_DIR}" "${result}" "result MATCHES \"/64bit/$\"")
+
+# check the both views are taken into account
+unset(result)
+find_path(result NAMES file32bit.txt HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW BOTH REQUIRED NO_CACHE NO_DEFAULT_PATH)
+check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/$\"")
+
+unset(result)
+find_path(result NAMES file64bit.txt HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW BOTH REQUIRED NO_CACHE NO_DEFAULT_PATH)
+check("${FILE_DIR}" "${result}" "result MATCHES \"/64bit/$\"")
+
+else() # 32bit
+
+ # no 64bit registry: file not found
+ unset(result)
+ find_path(result NAMES file.txt HINTS "${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_path(result NAMES file.txt HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32 REQUIRED NO_CACHE NO_DEFAULT_PATH)
+ check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/$\"")
+
+ unset(result)
+ find_path(result NAMES file.txt HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64_32 REQUIRED NO_CACHE NO_DEFAULT_PATH)
+ check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/$\"")
+
+ unset(result)
+ find_path(result NAMES file.txt HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32_64 REQUIRED NO_CACHE NO_DEFAULT_PATH)
+ check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/$\"")
+
+ unset(result)
+ find_path(result NAMES file.txt HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW BOTH REQUIRED NO_CACHE NO_DEFAULT_PATH)
+ check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/$\"")
+
+endif()
+
+
+if (ARCH STREQUAL "64bit")
+
+ # Check influence of variable CMAKE_SIZEOF_VOID_P
+ set(CMAKE_SIZEOF_VOID_P 8)
+ unset(result)
+ find_path(result NAMES file.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW TARGET REQUIRED NO_CACHE NO_DEFAULT_PATH)
+ check("${FILE_DIR}" "${result}" "result MATCHES \"/64bit/$\"")
+
+ unset(result)
+ find_path(result NAMES file.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW HOST REQUIRED NO_CACHE NO_DEFAULT_PATH)
+ check("${FILE_DIR}" "${result}" "result MATCHES \"/${ARCH}/$\"")
+
+
+ set(CMAKE_SIZEOF_VOID_P 4)
+ unset(result)
+ find_path(result NAMES file.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW TARGET REQUIRED NO_CACHE NO_DEFAULT_PATH)
+ check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/$\"")
+
+ unset(result)
+ find_path(result NAMES file.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW HOST REQUIRED NO_CACHE NO_DEFAULT_PATH)
+ check("${FILE_DIR}" "${result}" "result MATCHES \"/${ARCH}/$\"")
+
+ 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_path(result NAMES file.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" NO_CACHE REQUIRED NO_DEFAULT_PATH)
+ check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/$\"")
+
+ cmake_policy(SET CMP0134 NEW)
+ # CMAKE_SIZEOF_VOID_P is not set, so search first the HOST architecture registry
+ unset(result)
+ find_path(result NAMES file.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" NO_CACHE REQUIRED NO_DEFAULT_PATH)
+ check("${FILE_DIR}" "${result}" "result MATCHES \"/${ARCH}/$\"")
+
+endif()
diff --git a/Tests/RunCMake/find_path/RunCMakeTest.cmake b/Tests/RunCMake/find_path/RunCMakeTest.cmake
index 5b52f90..63cadc2 100644
--- a/Tests/RunCMake/find_path/RunCMakeTest.cmake
+++ b/Tests/RunCMake/find_path/RunCMakeTest.cmake
@@ -5,9 +5,37 @@ run_cmake(FromPATHEnv)
run_cmake(PrefixInPATH)
run_cmake(Required)
run_cmake(NO_CACHE)
+run_cmake(REGISTRY_VIEW-no-view)
+run_cmake(REGISTRY_VIEW-wrong-view)
if(APPLE)
run_cmake(FrameworksWithSubdirs)
endif()
run_cmake_with_options(FromPATHEnvDebugVar --debug-find-var=PATH_IN_ENV_PATH)
+
+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_path" /f OUTPUT_QUIET ERROR_QUIET)
+ if (ARCH STREQUAL "64bit")
+ execute_process(COMMAND "${REG}" delete "HKCU\\SOFTWARE\\Classes\\WOW6432Node\\CLSID\\CMake-Tests\\find_path" /f OUTPUT_QUIET ERROR_QUIET)
+ endif()
+ endif()
+endif()
diff --git a/Tests/RunCMake/find_path/default.32bit/file.txt b/Tests/RunCMake/find_path/default.32bit/file.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/find_path/default.32bit/file.txt
diff --git a/Tests/RunCMake/find_path/default.32bit/file32bit.txt b/Tests/RunCMake/find_path/default.32bit/file32bit.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/find_path/default.32bit/file32bit.txt
diff --git a/Tests/RunCMake/find_path/default.64bit/file.txt b/Tests/RunCMake/find_path/default.64bit/file.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/find_path/default.64bit/file.txt
diff --git a/Tests/RunCMake/find_path/default.64bit/file64bit.txt b/Tests/RunCMake/find_path/default.64bit/file64bit.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/find_path/default.64bit/file64bit.txt
diff --git a/Tests/RunCMake/find_path/registry_host32bit.reg b/Tests/RunCMake/find_path/registry_host32bit.reg
new file mode 100644
index 0000000..a56d79c
--- /dev/null
+++ b/Tests/RunCMake/find_path/registry_host32bit.reg
Binary files differ
diff --git a/Tests/RunCMake/find_path/registry_host64bit.reg b/Tests/RunCMake/find_path/registry_host64bit.reg
new file mode 100644
index 0000000..705b073
--- /dev/null
+++ b/Tests/RunCMake/find_path/registry_host64bit.reg
Binary files differ
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