1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-14 02:08:27 +08:00

cmFindBase: let the debug state know if it has already been found

This avoids reporting a "not found" state for searches that had cached
results.
This commit is contained in:
Ben Boeckel
2025-05-14 21:34:30 +02:00
committed by Brad King
parent 928a74f684
commit 5aefc8b7b8
3 changed files with 24 additions and 9 deletions

View File

@@ -90,6 +90,10 @@ bool cmFindBase::ParseArguments(std::vector<std::string> const& argsIn)
this->VariableName = args[0];
this->InitialState = this->GetInitialState();
if (this->IsFound()) {
if (this->DebugState) {
this->DebugState->FoundAt(
*this->Makefile->GetDefinition(this->VariableName));
}
return true;
}
@@ -524,6 +528,7 @@ bool cmFindBase::IsDefined() const
void cmFindBase::NormalizeFindResult()
{
std::string foundValue;
if (this->Makefile->GetPolicyStatus(cmPolicies::CMP0125) ==
cmPolicies::NEW) {
// ensure the path returned by find_* command is absolute
@@ -542,6 +547,7 @@ void cmFindBase::NormalizeFindResult()
}
}
foundValue = value;
if (this->StoreResultInCache) {
// If the user specifies the entry on the command line without a
// type we should add the type and docstring but keep the original
@@ -571,6 +577,10 @@ void cmFindBase::NormalizeFindResult()
// type we should add the type and docstring but keep the original
// value.
if (this->StoreResultInCache) {
auto const& existingValue =
this->Makefile->GetCMakeInstance()->GetCacheDefinition(
this->VariableName);
foundValue = *existingValue;
if (this->AlreadyInCacheWithoutMetaInfo) {
this->Makefile->AddCacheDefinition(this->VariableName, "",
this->VariableDocumentation,
@@ -578,19 +588,20 @@ void cmFindBase::NormalizeFindResult()
if (this->Makefile->GetPolicyStatus(cmPolicies::CMP0126) ==
cmPolicies::NEW &&
this->Makefile->IsNormalDefinitionSet(this->VariableName)) {
this->Makefile->AddDefinition(
this->VariableName,
*this->Makefile->GetCMakeInstance()->GetCacheDefinition(
this->VariableName));
this->Makefile->AddDefinition(this->VariableName, *existingValue);
}
}
} else {
auto const& existingValue =
this->Makefile->GetSafeDefinition(this->VariableName);
foundValue = existingValue;
// ensure a normal variable is defined.
this->Makefile->AddDefinition(
this->VariableName,
this->Makefile->GetSafeDefinition(this->VariableName));
this->Makefile->AddDefinition(this->VariableName, existingValue);
}
}
if (this->DebugState) {
this->DebugState->FoundAt(foundValue);
}
}
void cmFindBase::StoreFindResult(std::string const& value)
@@ -613,6 +624,10 @@ void cmFindBase::StoreFindResult(std::string const& value)
this->Makefile->AddDefinition(this->VariableName, value);
}
if (this->DebugState) {
this->DebugState->FoundAt(value);
}
return;
}

View File

@@ -26,4 +26,4 @@
find_path considered the following locations:.*
The item was found at.*
.*include/PrefixInPATH.*
.*find_path/include/

View File

@@ -26,4 +26,4 @@
find_path considered the following locations:.*
The item was found at.*
.*include/PrefixInPATH.*
.*find_path/include/