set(ENV_PATH "$ENV{PATH}")

set(CMAKE_FIND_DEBUG_MODE ON)
set(ENV{PATH} "${CMAKE_CURRENT_SOURCE_DIR}/PackageRoot")
find_package(Resolved QUIET)
set(CMAKE_FIND_DEBUG_MODE OFF)

foreach(path "/does_not_exist" "/PackageRoot" "")
  unset(Resolved_FOUND CACHE)
  set(Resolved_DIR "")
  set(ENV{PATH} "${CMAKE_CURRENT_SOURCE_DIR}${path}")
  find_package(Resolved QUIET)
  message(STATUS "Resolved_FOUND='${Resolved_FOUND}'")
endforeach()

set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH OFF)
foreach(path "/does_not_exist" "/PackageRoot" "")
  unset(Resolved_FOUND CACHE)
  set(Resolved_DIR "")
  set(ENV{PATH} "${CMAKE_CURRENT_SOURCE_DIR}${path}")
  find_package(Resolved QUIET)
  message(STATUS "Resolved_FOUND='${Resolved_FOUND}'")
endforeach()

set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH ON)
foreach(path "/does_not_exist" "/PackageRoot" "")
  unset(Resolved_FOUND CACHE)
  set(Resolved_DIR "")
  set(ENV{PATH} "${CMAKE_CURRENT_SOURCE_DIR}${path}")
  find_package(Resolved NO_SYSTEM_ENVIRONMENT_PATH QUIET)
  message(STATUS "Resolved_FOUND='${Resolved_FOUND}'")
endforeach()
set(ENV{PATH} "${ENV_PATH}")
