diff options
Diffstat (limited to 'Tests/RunCMake/find_path')
18 files changed, 260 insertions, 0 deletions
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 Binary files differnew file mode 100644 index 0000000..a56d79c --- /dev/null +++ b/Tests/RunCMake/find_path/registry_host32bit.reg diff --git a/Tests/RunCMake/find_path/registry_host64bit.reg b/Tests/RunCMake/find_path/registry_host64bit.reg Binary files differnew file mode 100644 index 0000000..705b073 --- /dev/null +++ b/Tests/RunCMake/find_path/registry_host64bit.reg |