mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-07 22:30:13 -06:00
find_package: Don't test <name>_DIR against ignored paths
Tweak `find_package` to not compare an already-specified `<name>_DIR`
against the set of ignored paths. This is a minor behavior change in
that, if a previously found package is in a location that is NEWLY
ignored (i.e. because the user modified the ignored paths since the
previous run of CMake), we won't throw out the old result. However, it
also means that a user specifying `<name>_DIR` takes precedence over the
set of ignored paths, which seems like the desired behavior.
Note that the current behavior was introduced in commit 11f97d1968
(find_package: Refactor CMAKE_[SYSTEM_]IGNORE_PATH, 2022-01-28,
v3.23.0-rc1~31^2) and appears to have been unintentional.
This commit is contained in:
committed by
Brad King
parent
65c1147e6c
commit
230e5ec172
@@ -12,6 +12,7 @@
|
||||
#include <utility>
|
||||
|
||||
#include <cm/optional>
|
||||
#include <cmext/algorithm>
|
||||
#include <cmext/string_view>
|
||||
|
||||
#include "cmsys/Directory.hxx"
|
||||
@@ -2422,8 +2423,12 @@ bool cmFindPackageCommand::CheckDirectory(std::string const& dir)
|
||||
{
|
||||
assert(!dir.empty() && dir.back() == '/');
|
||||
|
||||
// Look for the file in this directory.
|
||||
std::string const d = dir.substr(0, dir.size() - 1);
|
||||
if (cm::contains(this->IgnoredPaths, d)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Look for the file in this directory.
|
||||
if (this->FindConfigFile(d, this->FileFound)) {
|
||||
// Remove duplicate slashes.
|
||||
cmSystemTools::ConvertToUnixSlashes(this->FileFound);
|
||||
@@ -2435,10 +2440,6 @@ bool cmFindPackageCommand::CheckDirectory(std::string const& dir)
|
||||
bool cmFindPackageCommand::FindConfigFile(std::string const& dir,
|
||||
std::string& file)
|
||||
{
|
||||
if (this->IgnoredPaths.count(dir)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (std::string const& c : this->Configs) {
|
||||
file = cmStrCat(dir, '/', c);
|
||||
if (this->DebugMode) {
|
||||
|
||||
Reference in New Issue
Block a user