diff options
author | Matthew Woehlke <matthew.woehlke@kitware.com> | 2024-10-23 16:24:44 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2024-10-23 16:46:07 (GMT) |
commit | 630e4a12a30a60a0284a86fdf991e840e0b353c0 (patch) | |
tree | f870532805ee163a1e91e901ba91e0a3a382e572 /Tests | |
parent | 67688208263a478d28d7d7ed0fee75873d86eb81 (diff) | |
download | CMake-630e4a12a30a60a0284a86fdf991e840e0b353c0.zip CMake-630e4a12a30a60a0284a86fdf991e840e0b353c0.tar.gz CMake-630e4a12a30a60a0284a86fdf991e840e0b353c0.tar.bz2 |
Help: Fix find_package search order w.r.t. globs
Add documentation to clarify that `find_package` searches paths in the
specified order and stops at the first match. Clarify documentation of
`CMAKE_FIND_PACKAGE_SORT_*` to match the actual behavior.
Note that no behavior is actually changed, this merely improves the
documentation to reflect actual behavior rather than seeming to imply
something else.
Also, update the test to verify that what we claim in the updated
documentation is what's actually happening.
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/FindPackageTest/CMakeLists.txt | 8 | ||||
-rw-r--r-- | Tests/FindPackageTest/lib/SortLib-4.0.0/SortLibConfig.cmake | 2 | ||||
-rw-r--r-- | Tests/FindPackageTest/lib/SortLib-4.0.0/SortLibConfigVersion.cmake | 9 |
3 files changed, 19 insertions, 0 deletions
diff --git a/Tests/FindPackageTest/CMakeLists.txt b/Tests/FindPackageTest/CMakeLists.txt index f30287f..73d3fb4 100644 --- a/Tests/FindPackageTest/CMakeLists.txt +++ b/Tests/FindPackageTest/CMakeLists.txt @@ -571,6 +571,14 @@ endif() set(SortLib_DIR "" CACHE FILEPATH "Wipe out find results for testing." FORCE) unset(SortLib_VERSION) + +set(SortLib_DIR "" CACHE FILEPATH "Wipe out find results for testing." FORCE) +FIND_PACKAGE(SortLib 4.0 CONFIG) +IF (NOT "${SortLib_VERSION}" STREQUAL "4.0.0") + message(SEND_ERROR "FIND_PACKAGE_SORT_ORDER gave up too soon! ${SortLib_VERSION}") +endif() +unset(SortLib_VERSION) + unset(CMAKE_FIND_PACKAGE_SORT_ORDER) unset(CMAKE_FIND_PACKAGE_SORT_DIRECTION) set(CMAKE_PREFIX_PATH ) diff --git a/Tests/FindPackageTest/lib/SortLib-4.0.0/SortLibConfig.cmake b/Tests/FindPackageTest/lib/SortLib-4.0.0/SortLibConfig.cmake new file mode 100644 index 0000000..845e6c7 --- /dev/null +++ b/Tests/FindPackageTest/lib/SortLib-4.0.0/SortLibConfig.cmake @@ -0,0 +1,2 @@ +set(SORT_LIB_VERSION 4.0.0) +message("SortLib 4.0.0 config reached") diff --git a/Tests/FindPackageTest/lib/SortLib-4.0.0/SortLibConfigVersion.cmake b/Tests/FindPackageTest/lib/SortLib-4.0.0/SortLibConfigVersion.cmake new file mode 100644 index 0000000..b642dab --- /dev/null +++ b/Tests/FindPackageTest/lib/SortLib-4.0.0/SortLibConfigVersion.cmake @@ -0,0 +1,9 @@ +set(PACKAGE_VERSION 4.0.0) +if(PACKAGE_FIND_VERSION_MAJOR EQUAL 4) + if(PACKAGE_FIND_VERSION_MINOR EQUAL 0) + set(PACKAGE_VERSION_COMPATIBLE 1) + if(PACKAGE_FIND_VERSION_PATCH EQUAL 0) + set(PACKAGE_VERSION_EXACT 1) + endif() + endif() +endif() |