mirror of
https://github.com/Kitware/CMake.git
synced 2026-11-08 06:16:53 +00:00
find_package: Save package information only after successfully loading it
If a package configuration file sets `<PackageName>_FOUND` to false, the package is considered not found. Do not save its package info. Note that this exposes an existing pointer invalidation on nested `find_package` calls, which will be fixed in following commits. Issue: #27730
This commit is contained in:
1 parent
2b22c2a45f
commit
5aa649d5f6
1 file changed
+6
-2
@@ -1732,6 +1732,12 @@ bool cmFindPackageCommand::HandlePackageMode(
|
||||
// The configuration file is invalid.
|
||||
result = false;
|
||||
}
|
||||
|
||||
if (this->UseConfigFiles && found) {
|
||||
this->CurrentPackageInfo->Directory =
|
||||
cmSystemTools::GetFilenamePath(this->FileFound);
|
||||
this->CurrentPackageInfo->Version = this->VersionFound;
|
||||
}
|
||||
}
|
||||
|
||||
if (this->UseFindModules && !found &&
|
||||
@@ -1975,8 +1981,6 @@ bool cmFindPackageCommand::FindConfig()
|
||||
std::string init;
|
||||
if (found) {
|
||||
init = cmSystemTools::GetFilenamePath(this->FileFound);
|
||||
this->CurrentPackageInfo->Directory = init;
|
||||
this->CurrentPackageInfo->Version = this->VersionFound;
|
||||
} else {
|
||||
init = this->Variable + "-NOTFOUND";
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user