find_package: Fix CMAKE_FIND_PACKAGE_SORT_DIRECTION documented default
Previously the documentation said the default was `DEC`, but the implementation has always defaulted to `ASC`. Fixes: #22728
This commit is contained in:
parent
a29c2e1cf0
commit
0e2b87244c
@ -6,13 +6,13 @@ CMAKE_FIND_PACKAGE_SORT_DIRECTION
|
||||
The sorting direction used by :variable:`CMAKE_FIND_PACKAGE_SORT_ORDER`.
|
||||
It can assume one of the following values:
|
||||
|
||||
``DEC``
|
||||
Default. Ordering is done in descending mode.
|
||||
The highest folder found will be tested first.
|
||||
|
||||
``ASC``
|
||||
Ordering is done in ascending mode.
|
||||
Default. Ordering is done in ascending mode.
|
||||
The lowest folder found will be tested first.
|
||||
|
||||
``DEC``
|
||||
Ordering is done in descending mode.
|
||||
The highest folder found will be tested first.
|
||||
|
||||
If :variable:`CMAKE_FIND_PACKAGE_SORT_ORDER` is not set or is set to ``NONE``
|
||||
this variable has no effect.
|
||||
|
@ -678,7 +678,7 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args)
|
||||
}
|
||||
if (cmValue const sd =
|
||||
this->Makefile->GetDefinition("CMAKE_FIND_PACKAGE_SORT_DIRECTION")) {
|
||||
this->SortDirection = (*sd == "ASC") ? Asc : Dec;
|
||||
this->SortDirection = (*sd == "DEC") ? Dec : Asc;
|
||||
}
|
||||
|
||||
// Find what search path locations have been enabled/disable.
|
||||
|
@ -554,14 +554,15 @@ endif()
|
||||
##Test FIND_PACKAGE using sorting
|
||||
set(CMAKE_PREFIX_PATH ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
set(SortLib_DIR "" CACHE FILEPATH "Wipe out find results for testing." FORCE)
|
||||
SET(CMAKE_FIND_PACKAGE_SORT_ORDER NAME)
|
||||
SET(CMAKE_FIND_PACKAGE_SORT_DIRECTION ASC)
|
||||
FIND_PACKAGE(SortLib CONFIG)
|
||||
IF (NOT "${SortLib_VERSION}" STREQUAL "3.1.1")
|
||||
message(SEND_ERROR "FIND_PACKAGE_SORT_ORDER Name Asc! ${SortLib_VERSION}")
|
||||
endif()
|
||||
unset(SortLib_VERSION)
|
||||
foreach(CMAKE_FIND_PACKAGE_SORT_DIRECTION IN ITEMS "" ASC Bogus)
|
||||
set(SortLib_DIR "" CACHE FILEPATH "Wipe out find results for testing." FORCE)
|
||||
SET(CMAKE_FIND_PACKAGE_SORT_ORDER NAME)
|
||||
FIND_PACKAGE(SortLib CONFIG)
|
||||
IF (NOT "${SortLib_VERSION}" STREQUAL "3.1.1")
|
||||
message(SEND_ERROR "FIND_PACKAGE_SORT_ORDER Name Asc! ${SortLib_VERSION}")
|
||||
endif()
|
||||
unset(SortLib_VERSION)
|
||||
endforeach()
|
||||
|
||||
|
||||
set(SortLib_DIR "" CACHE FILEPATH "Wipe out find results for testing." FORCE)
|
||||
|
@ -80,14 +80,15 @@ endif()
|
||||
###############################################################################
|
||||
# Test glob sorting.
|
||||
|
||||
set(SortLib_DIR "" CACHE FILEPATH "Wipe out find results for testing." FORCE)
|
||||
set(CMAKE_FIND_PACKAGE_SORT_ORDER NAME)
|
||||
set(CMAKE_FIND_PACKAGE_SORT_DIRECTION ASC)
|
||||
find_package(SortLib CONFIG)
|
||||
if(NOT "${SortLib_VERSION}" STREQUAL "3.1.1")
|
||||
message(SEND_ERROR "FIND_PACKAGE_SORT_ORDER Name Asc! ${SortLib_VERSION}")
|
||||
endif()
|
||||
unset(SortLib_VERSION)
|
||||
foreach(CMAKE_FIND_PACKAGE_SORT_DIRECTION IN ITEMS "" ASC Bogus)
|
||||
set(SortLib_DIR "" CACHE FILEPATH "Wipe out find results for testing." FORCE)
|
||||
set(CMAKE_FIND_PACKAGE_SORT_ORDER NAME)
|
||||
find_package(SortLib CONFIG)
|
||||
if(NOT "${SortLib_VERSION}" STREQUAL "3.1.1")
|
||||
message(SEND_ERROR "FIND_PACKAGE_SORT_ORDER Name Asc! ${SortLib_VERSION}")
|
||||
endif()
|
||||
unset(SortLib_VERSION)
|
||||
endforeach()
|
||||
|
||||
set(SortLib_DIR "" CACHE FILEPATH "Wipe out find results for testing." FORCE)
|
||||
set(CMAKE_FIND_PACKAGE_SORT_ORDER NATURAL)
|
||||
|
Loading…
Reference in New Issue
Block a user