23765d41c63e2307aa50fecba2bf2660b5fd1d31
[platform/upstream/cmake.git] / Tests / RunCMake / find_file / RunCMakeTest.cmake
1 include(RunCMake)
2
3 run_cmake(FromPATHEnv)
4 run_cmake(FromPrefixPath)
5 run_cmake(PrefixInPATH)
6 run_cmake(Required)
7 run_cmake(NO_CACHE)
8 run_cmake(REGISTRY_VIEW-no-view)
9 run_cmake(REGISTRY_VIEW-wrong-view)
10
11 run_cmake_with_options(FromPATHEnvDebugVar --debug-find-var=PrefixInPATH_File)
12
13 if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
14   # Tests using the Windows registry
15   find_program(REG NAMES "reg.exe" NO_CACHE)
16   if (REG)
17     ## check host architecture
18     cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "HKCU" SUBKEYS VIEW 64 ERROR_VARIABLE status)
19     if (status STREQUAL "")
20       set(ARCH "64bit")
21     else()
22       set(ARCH "32bit")
23     endif()
24
25     # crete some entries in the registry
26     cmake_path(CONVERT "${RunCMake_SOURCE_DIR}/registry_host${ARCH}.reg" TO_NATIVE_PATH_LIST registry_data)
27     execute_process(COMMAND "${REG}" import "${registry_data}" OUTPUT_QUIET ERROR_QUIET)
28
29     run_cmake_with_options(Registry-query -DARCH=${ARCH})
30
31     # clean-up registry
32     execute_process(COMMAND "${REG}" delete "HKCU\\SOFTWARE\\Classes\\CLSID\\CMake-Tests\\find_file" /f OUTPUT_QUIET ERROR_QUIET)
33     if (ARCH STREQUAL "64bit")
34       execute_process(COMMAND "${REG}" delete "HKCU\\SOFTWARE\\Classes\\WOW6432Node\\CLSID\\CMake-Tests\\find_file" /f OUTPUT_QUIET ERROR_QUIET)
35     endif()
36   endif()
37 endif()