|
|
@@ -1522,6 +1522,7 @@ bool cmFindPackageCommand::HandlePackageMode(
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ std::string const fileVar = cmStrCat(this->Name, "_CONFIG");
|
|
|
std::string const foundVar = cmStrCat(this->Name, "_FOUND");
|
|
|
std::string const notFoundMessageVar =
|
|
|
cmStrCat(this->Name, "_NOT_FOUND_MESSAGE");
|
|
|
@@ -1552,7 +1553,15 @@ bool cmFindPackageCommand::HandlePackageMode(
|
|
|
if (this->CpsReader) {
|
|
|
// The package has been found.
|
|
|
found = true;
|
|
|
- result = this->ReadPackage();
|
|
|
+
|
|
|
+ // Don't read a CPS file if we've already read it.
|
|
|
+ cmValue const& previousFileFound =
|
|
|
+ this->Makefile->GetDefinition(fileVar);
|
|
|
+ if (previousFileFound.Compare(this->FileFound) == 0) {
|
|
|
+ result = true;
|
|
|
+ } else {
|
|
|
+ result = this->ReadPackage();
|
|
|
+ }
|
|
|
} else if (this->ReadListFile(this->FileFound, DoPolicyScope)) {
|
|
|
// The package has been found.
|
|
|
found = true;
|
|
|
@@ -1725,7 +1734,6 @@ bool cmFindPackageCommand::HandlePackageMode(
|
|
|
this->Makefile->AddDefinition(foundVar, found ? "1" : "0");
|
|
|
|
|
|
// Set a variable naming the configuration file that was found.
|
|
|
- std::string const fileVar = cmStrCat(this->Name, "_CONFIG");
|
|
|
if (found) {
|
|
|
this->Makefile->AddDefinition(fileVar, this->FileFound);
|
|
|
} else {
|