Imported Upstream version 3.25.0
[platform/upstream/cmake.git] / Tests / RunCMake / find_program / RunCMakeTest.cmake
1 include(RunCMake)
2
3 run_cmake(EnvAndHints)
4 run_cmake(DirsPerName)
5 run_cmake(NamesPerDir)
6 run_cmake(RelAndAbsPath)
7 run_cmake(Required)
8 run_cmake(NO_CACHE)
9 run_cmake(IgnorePrefixPath)
10 run_cmake(REGISTRY_VIEW-no-view)
11 run_cmake(REGISTRY_VIEW-wrong-view)
12 run_cmake(VALIDATOR-no-function)
13 run_cmake(VALIDATOR-undefined-function)
14 run_cmake(VALIDATOR-specify-macro)
15 run_cmake(VALIDATOR)
16
17 if(CMAKE_SYSTEM_NAME MATCHES "^(Windows|CYGWIN|MSYS)$")
18   run_cmake(WindowsCom)
19   run_cmake(WindowsExe)
20 else()
21   # test non readable file only if not root
22   execute_process(
23     COMMAND id -u $ENV{USER}
24     OUTPUT_VARIABLE uid
25     OUTPUT_STRIP_TRAILING_WHITESPACE)
26
27   if(NOT "${uid}" STREQUAL "0")
28     run_cmake(CMP0109-WARN)
29     run_cmake(CMP0109-OLD)
30     run_cmake(CMP0109-NEW)
31   endif()
32 endif()
33
34 if(APPLE)
35   run_cmake(BundleSpaceInName)
36 endif()
37
38 run_cmake_with_options(EnvAndHintsDebugVar --debug-find-var=PROG)
39
40 if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
41   # Tests using the Windows registry
42   find_program(REG NAMES "reg.exe" NO_CACHE)
43   if (REG)
44     ## check host architecture
45     cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "HKCU" SUBKEYS VIEW 64 ERROR_VARIABLE status)
46     if (status STREQUAL "")
47       set(ARCH "64bit")
48     else()
49       set(ARCH "32bit")
50     endif()
51
52     # crete some entries in the registry
53     cmake_path(CONVERT "${RunCMake_SOURCE_DIR}/registry_host${ARCH}.reg" TO_NATIVE_PATH_LIST registry_data)
54     execute_process(COMMAND "${REG}" import "${registry_data}" OUTPUT_QUIET ERROR_QUIET)
55
56     run_cmake_with_options(Registry-query -DARCH=${ARCH})
57
58     # clean-up registry
59     execute_process(COMMAND "${REG}" delete "HKCU\\SOFTWARE\\Classes\\CLSID\\CMake-Tests\\find_program" /f OUTPUT_QUIET ERROR_QUIET)
60     if (ARCH STREQUAL "64bit")
61       execute_process(COMMAND "${REG}" delete "HKCU\\SOFTWARE\\Classes\\WOW6432Node\\CLSID\\CMake-Tests\\find_program" /f OUTPUT_QUIET ERROR_QUIET)
62     endif()
63   endif()
64 endif()