MCPcopy Create free account
hub / github.com/Kitware/CMake / NormalizeFindResult

Method NormalizeFindResult

Source/cmFindBase.cxx:527–603  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

525}
526
527void cmFindBase::NormalizeFindResult()
528{
529 std::string foundValue;
530 if (this->Makefile->GetPolicyStatus(cmPolicies::CMP0125) ==
531 cmPolicies::NEW) {
532 // ensure the path returned by find_* command is absolute
533 auto const& existingValue =
534 this->Makefile->GetDefinition(this->VariableName);
535 std::string value;
536 if (!existingValue->empty()) {
537 value =
538 cmCMakePath(*existingValue, cmCMakePath::auto_format)
539 .Absolute(cmCMakePath(
540 this->Makefile->GetCMakeInstance()->GetCMakeWorkingDirectory()))
541 .Normal()
542 .GenericString();
543 if (!cmSystemTools::FileExists(value, false)) {
544 value = *existingValue;
545 }
546 }
547
548 foundValue = value;
549 if (this->StoreResultInCache) {
550 // If the user specifies the entry on the command line without a
551 // type we should add the type and docstring but keep the original
552 // value.
553 if (value != *existingValue || this->AlreadyInCacheWithoutMetaInfo) {
554 this->Makefile->GetCMakeInstance()->AddCacheEntry(
555 this->VariableName, value, this->VariableDocumentation,
556 this->VariableType);
557 if (this->Makefile->GetPolicyStatus(cmPolicies::CMP0126) ==
558 cmPolicies::NEW) {
559 if (this->Makefile->IsNormalDefinitionSet(this->VariableName)) {
560 this->Makefile->AddDefinition(this->VariableName, value);
561 }
562 } else {
563 // if there was a definition then remove it
564 // This is required to ensure same behavior as
565 // cmMakefile::AddCacheDefinition.
566 this->Makefile->RemoveDefinition(this->VariableName);
567 }
568 }
569 } else {
570 // ensure a normal variable is defined.
571 this->Makefile->AddDefinition(this->VariableName, value);
572 }
573 } else {
574 // If the user specifies the entry on the command line without a
575 // type we should add the type and docstring but keep the original
576 // value.
577 if (this->StoreResultInCache) {
578 auto const& existingValue =
579 this->Makefile->GetCMakeInstance()->GetCacheDefinition(
580 this->VariableName);
581 foundValue = *existingValue;
582 if (this->AlreadyInCacheWithoutMetaInfo) {
583 this->Makefile->AddCacheDefinition(this->VariableName, "",
584 this->VariableDocumentation,

Callers 3

InitialPassMethod · 0.80
InitialPassMethod · 0.80
InitialPassMethod · 0.80

Calls 15

cmCMakePathClass · 0.85
GenericStringMethod · 0.80
NormalMethod · 0.80
IsNormalDefinitionSetMethod · 0.80
GetCacheDefinitionMethod · 0.80
FoundAtMethod · 0.80
FileExistsFunction · 0.50
GetPolicyStatusMethod · 0.45
GetDefinitionMethod · 0.45
emptyMethod · 0.45
AbsoluteMethod · 0.45
GetCMakeInstanceMethod · 0.45

Tested by

no test coverage detected