diff options
author | Robert Maynard <rmaynard@nvidia.com> | 2022-03-21 19:05:39 (GMT) |
---|---|---|
committer | Robert Maynard <rmaynard@nvidia.com> | 2022-04-15 13:33:55 (GMT) |
commit | 42f7e397894c5132b4706f478e62ce5d648119c1 (patch) | |
tree | cbc53e9c4fad5d12e3c724011770a377fc572890 /Tests/RunCMake/no_install_prefix | |
parent | 7fc248bde34c529c6f1312a56c7e82303238b9c1 (diff) | |
download | CMake-42f7e397894c5132b4706f478e62ce5d648119c1.zip CMake-42f7e397894c5132b4706f478e62ce5d648119c1.tar.gz CMake-42f7e397894c5132b4706f478e62ce5d648119c1.tar.bz2 |
Find: Support per call disabling of CMAKE_INSTALL_PREFIX
Fixes #23359
Diffstat (limited to 'Tests/RunCMake/no_install_prefix')
-rw-r--r-- | Tests/RunCMake/no_install_prefix/RunCMakeTest.cmake | 2 | ||||
-rw-r--r-- | Tests/RunCMake/no_install_prefix/do_test.cmake | 14 | ||||
-rw-r--r-- | Tests/RunCMake/no_install_prefix/no_install_prefix-stderr.txt | 2 |
3 files changed, 16 insertions, 2 deletions
diff --git a/Tests/RunCMake/no_install_prefix/RunCMakeTest.cmake b/Tests/RunCMake/no_install_prefix/RunCMakeTest.cmake index 2923449..eb0ff23 100644 --- a/Tests/RunCMake/no_install_prefix/RunCMakeTest.cmake +++ b/Tests/RunCMake/no_install_prefix/RunCMakeTest.cmake @@ -11,5 +11,5 @@ run_cmake(with_install_prefix) file(REMOVE_RECURSE "${RunCMake_BINARY_DIR}/prefix") file(MAKE_DIRECTORY "${RunCMake_BINARY_DIR}/prefix/NoPrefix") file(WRITE "${RunCMake_BINARY_DIR}/prefix/NoPrefix/NoPrefixConfig.cmake" "") -list(APPEND RunCMake_TEST_OPTIONS "-DCMAKE_FIND_NO_INSTALL_PREFIX=1") +list(APPEND RunCMake_TEST_OPTIONS "-DCMAKE_FIND_NO_INSTALL_PREFIX=1" "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_BINARY_DIR}/prefix") run_cmake(no_install_prefix) diff --git a/Tests/RunCMake/no_install_prefix/do_test.cmake b/Tests/RunCMake/no_install_prefix/do_test.cmake index 340c7dc..ce94b50 100644 --- a/Tests/RunCMake/no_install_prefix/do_test.cmake +++ b/Tests/RunCMake/no_install_prefix/do_test.cmake @@ -1,2 +1,16 @@ +find_package(NoPrefix NO_CMAKE_INSTALL_PREFIX) +if(NoPrefix_FOUND) + message(FATAL_ERROR "Should not find package when NO_CMAKE_INSTALL_PREFIX specified") +endif() + +set(CMAKE_FIND_USE_INSTALL_PREFIX ON) +find_package(NoPrefix) +if(NOT NoPrefix_FOUND) + message(FATAL_ERROR "Should always find package when CMAKE_FIND_USE_INSTALL_PREFIX is enabled") +endif() + +unset(CMAKE_FIND_USE_INSTALL_PREFIX) +unset(NoPrefix_DIR CACHE) + find_package(NoPrefix REQUIRED) diff --git a/Tests/RunCMake/no_install_prefix/no_install_prefix-stderr.txt b/Tests/RunCMake/no_install_prefix/no_install_prefix-stderr.txt index 66c6241..52bd094 100644 --- a/Tests/RunCMake/no_install_prefix/no_install_prefix-stderr.txt +++ b/Tests/RunCMake/no_install_prefix/no_install_prefix-stderr.txt @@ -1,4 +1,4 @@ -CMake Error at do_test.cmake:2 \(find_package\): +CMake Error at do_test.cmake:16 \(find_package\): By not providing "FindNoPrefix.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "NoPrefix", but CMake did not find one. |