summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/find_path/FromPATHEnv.cmake
blob: 535e62437f4db70b388de501e147df72dfaea8b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
set(ENV_PATH "$ENV{PATH}")

set(CMAKE_FIND_DEBUG_MODE 1)
set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH OFF)

set(ENV{PATH} "${CMAKE_CURRENT_SOURCE_DIR}/include")
find_path(PATH_IN_ENV_PATH NAMES PrefixInPATH.h)

set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH ON)
find_path(PATH_IN_ENV_PATH NAMES PrefixInPATH.h)

set(CMAKE_FIND_DEBUG_MODE 0)

foreach(path "/does_not_exist" "/include" "")
  unset(PATH_IN_ENV_PATH CACHE)
  set(ENV{PATH} "${CMAKE_CURRENT_SOURCE_DIR}${path}")
  find_path(PATH_IN_ENV_PATH NAMES PrefixInPATH.h)
  message(STATUS "PATH_IN_ENV_PATH='${PATH_IN_ENV_PATH}'")
endforeach()

set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH OFF)
foreach(path "/does_not_exist" "/include" "")
  unset(PATH_IN_ENV_PATH CACHE)
  set(ENV{PATH} "${CMAKE_CURRENT_SOURCE_DIR}${path}")
  find_path(PATH_IN_ENV_PATH NAMES PrefixInPATH.h)
  message(STATUS "PATH_IN_ENV_PATH='${PATH_IN_ENV_PATH}'")
endforeach()

set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH ON)
foreach(path "/does_not_exist" "/include" "")
  unset(PATH_IN_ENV_PATH CACHE)
  set(ENV{PATH} "${CMAKE_CURRENT_SOURCE_DIR}${path}")
  find_path(PATH_IN_ENV_PATH NAMES PrefixInPATH.h NO_SYSTEM_ENVIRONMENT_PATH)
  message(STATUS "PATH_IN_ENV_PATH='${PATH_IN_ENV_PATH}'")
endforeach()

set(ENV{PATH} "${ENV_PATH}")