diff options
author | Kyle Edwards <kyle.edwards@kitware.com> | 2022-01-26 21:35:54 (GMT) |
---|---|---|
committer | Kyle Edwards <kyle.edwards@kitware.com> | 2022-02-02 16:09:00 (GMT) |
commit | 201d8c429843e9e57f833fcca8794f532e6d3028 (patch) | |
tree | a66090c1d5445466e189f149a11c1b1bfde84667 /Tests/RunCMake | |
parent | bd805a51ae4b5be5be6bbadf4afab108fcf4ddb3 (diff) | |
download | CMake-201d8c429843e9e57f833fcca8794f532e6d3028.zip CMake-201d8c429843e9e57f833fcca8794f532e6d3028.tar.gz CMake-201d8c429843e9e57f833fcca8794f532e6d3028.tar.bz2 |
find_*(): Add CMAKE_IGNORE_PREFIX_PATH variable
Fixes: #20878
Diffstat (limited to 'Tests/RunCMake')
-rw-r--r-- | Tests/RunCMake/find_package/IgnorePrefixPath.cmake | 26 | ||||
-rw-r--r-- | Tests/RunCMake/find_package/RunCMakeTest.cmake | 1 | ||||
-rw-r--r-- | Tests/RunCMake/find_program/IgnorePrefixPath.cmake | 30 | ||||
-rwxr-xr-x | Tests/RunCMake/find_program/Prefix/bin/prog | 1 | ||||
-rw-r--r-- | Tests/RunCMake/find_program/RunCMakeTest.cmake | 1 | ||||
-rwxr-xr-x | Tests/RunCMake/find_program/SystemPrefix/bin/prog | 1 |
6 files changed, 60 insertions, 0 deletions
diff --git a/Tests/RunCMake/find_package/IgnorePrefixPath.cmake b/Tests/RunCMake/find_package/IgnorePrefixPath.cmake new file mode 100644 index 0000000..65709a2 --- /dev/null +++ b/Tests/RunCMake/find_package/IgnorePrefixPath.cmake @@ -0,0 +1,26 @@ +set(CMAKE_PREFIX_PATH + ${CMAKE_SOURCE_DIR}/PackageRoot/foo/cmake_root + ${CMAKE_SOURCE_DIR}/PackageRoot/foo/env_root + ) +set(CMAKE_IGNORE_PREFIX_PATH + ${CMAKE_SOURCE_DIR}/PackageRoot//foo/cmake_root// # Test double slashes + ) +set(CMAKE_SYSTEM_IGNORE_PREFIX_PATH + ${CMAKE_SOURCE_DIR}/PackageRoot/foo/env_root + ) +find_package(Bar QUIET CONFIG) +if(Bar_FOUND) + message(SEND_ERROR "Bar should not be found, was found in ${Bar_DIR}") +endif() + +set(CMAKE_PREFIX_PATH) +set(CMAKE_FIND_ROOT_PATH + ${CMAKE_SOURCE_DIR}/PackageRoot/foo/cmake_root + ${CMAKE_SOURCE_DIR}/PackageRoot/foo/env_root + ) +set(CMAKE_IGNORE_PREFIX_PATH /) +set(CMAKE_SYSTEM_IGNORE_PREFIX_PATH) +find_package(Bar2 NAMES Bar QUIET CONFIG) +if(Bar2_FOUND) + message(SEND_ERROR "Bar2 should not be found, was found in ${Bar2_DIR}") +endif() diff --git a/Tests/RunCMake/find_package/RunCMakeTest.cmake b/Tests/RunCMake/find_package/RunCMakeTest.cmake index 12701dc..037502f 100644 --- a/Tests/RunCMake/find_package/RunCMakeTest.cmake +++ b/Tests/RunCMake/find_package/RunCMakeTest.cmake @@ -45,6 +45,7 @@ run_cmake(VersionRangeConfig02) run_cmake(VersionRangeConfigStd) run_cmake(VersionRangeConfigStd2) run_cmake(IgnorePath) +run_cmake(IgnorePrefixPath) if(UNIX AND NOT MSYS # FIXME: This works on CYGWIN but not on MSYS ) diff --git a/Tests/RunCMake/find_program/IgnorePrefixPath.cmake b/Tests/RunCMake/find_program/IgnorePrefixPath.cmake new file mode 100644 index 0000000..5f0dba9 --- /dev/null +++ b/Tests/RunCMake/find_program/IgnorePrefixPath.cmake @@ -0,0 +1,30 @@ +function(assert_eq var value) + if(NOT "${${var}}" STREQUAL "${value}") + message(SEND_ERROR "Expected value of ${var}:\n ${value}\nActual value:\n ${${var}}") + endif() +endfunction() + +set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH FALSE) + +set(CMAKE_PREFIX_PATH ${CMAKE_SOURCE_DIR}/Prefix) +set(_old_CMAKE_SYSTEM_PREFIX_PATH ${CMAKE_SYSTEM_PREFIX_PATH}) +set(CMAKE_SYSTEM_PREFIX_PATH ${CMAKE_SOURCE_DIR}/SystemPrefix) +set(prog_ROOT + ${CMAKE_SOURCE_DIR}/Prefix + ${CMAKE_SOURCE_DIR}/SystemPrefix + ) + +set(CMAKE_IGNORE_PREFIX_PATH ${CMAKE_SOURCE_DIR}/Prefix) +set(CMAKE_SYSTEM_IGNORE_PREFIX_PATH ${CMAKE_SOURCE_DIR}/SystemPrefix) +find_program(prog prog) +assert_eq(prog "prog-NOTFOUND") + +set(CMAKE_PREFIX_PATH) +set(CMAKE_SYSTEM_PREFIX_PATH ${_old_CMAKE_SYSTEM_PREFIX_PATH}) +set(CMAKE_IGNORE_PREFIX_PATH /) +set(CMAKE_FIND_ROOT_PATH + ${CMAKE_SOURCE_DIR}/Prefix + ${CMAKE_SOURCE_DIR}/SystemPrefix + ) +find_program(prog2 prog) +assert_eq(prog2 "prog2-NOTFOUND") diff --git a/Tests/RunCMake/find_program/Prefix/bin/prog b/Tests/RunCMake/find_program/Prefix/bin/prog new file mode 100755 index 0000000..1a24852 --- /dev/null +++ b/Tests/RunCMake/find_program/Prefix/bin/prog @@ -0,0 +1 @@ +#!/bin/sh diff --git a/Tests/RunCMake/find_program/RunCMakeTest.cmake b/Tests/RunCMake/find_program/RunCMakeTest.cmake index 2a1dae4..c2c07af 100644 --- a/Tests/RunCMake/find_program/RunCMakeTest.cmake +++ b/Tests/RunCMake/find_program/RunCMakeTest.cmake @@ -6,6 +6,7 @@ run_cmake(NamesPerDir) run_cmake(RelAndAbsPath) run_cmake(Required) run_cmake(NO_CACHE) +run_cmake(IgnorePrefixPath) if(CMAKE_SYSTEM_NAME MATCHES "^(Windows|CYGWIN|MSYS)$") run_cmake(WindowsCom) diff --git a/Tests/RunCMake/find_program/SystemPrefix/bin/prog b/Tests/RunCMake/find_program/SystemPrefix/bin/prog new file mode 100755 index 0000000..1a24852 --- /dev/null +++ b/Tests/RunCMake/find_program/SystemPrefix/bin/prog @@ -0,0 +1 @@ +#!/bin/sh |