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

Method FindModule

Source/cmFindPackageCommand.cxx:1543–1624  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1541}
1542
1543bool cmFindPackageCommand::FindModule(bool& found)
1544{
1545 std::string moduleFileName = cmStrCat("Find", this->Name, ".cmake");
1546
1547 bool system = false;
1548 std::string debugBuffer = cmStrCat(
1549 "find_package considered the following paths for ", moduleFileName, ":\n");
1550 std::string mfile = this->Makefile->GetModulesFile(
1551 moduleFileName, system, this->DebugModeEnabled(), debugBuffer);
1552 if (this->DebugModeEnabled()) {
1553 if (mfile.empty()) {
1554 debugBuffer = cmStrCat(debugBuffer, "The file was not found.\n");
1555 } else {
1556 debugBuffer =
1557 cmStrCat(debugBuffer, "The file was found at\n ", mfile, '\n');
1558 }
1559 this->DebugBuffer = cmStrCat(this->DebugBuffer, debugBuffer);
1560 }
1561
1562 if (!mfile.empty()) {
1563 if (system) {
1564 auto const it = this->DeprecatedFindModules.find(this->Name);
1565 if (it != this->DeprecatedFindModules.end()) {
1566 cmPolicies::PolicyStatus status =
1567 this->Makefile->GetPolicyStatus(it->second);
1568 switch (status) {
1569 case cmPolicies::WARN: {
1570 this->Makefile->IssueMessage(
1571 MessageType::AUTHOR_WARNING,
1572 cmStrCat(cmPolicies::GetPolicyWarning(it->second), '\n'));
1573 CM_FALLTHROUGH;
1574 }
1575 case cmPolicies::OLD:
1576 break;
1577 case cmPolicies::NEW:
1578 return true;
1579 }
1580 }
1581 }
1582
1583 // Load the module we found, and set "<name>_FIND_MODULE" to true
1584 // while inside it.
1585 found = true;
1586 std::string const var = cmStrCat(this->Name, "_FIND_MODULE");
1587 this->Makefile->AddDefinition(var, "1");
1588 bool result = this->ReadListFile(mfile, DoPolicyScope);
1589 this->Makefile->RemoveDefinition(var);
1590
1591 std::string const foundVar = cmStrCat(this->Name, "_FOUND");
1592 if (this->Makefile->IsDefinitionSet(foundVar) &&
1593 !this->Makefile->IsOn(foundVar)) {
1594
1595 if (this->DebugModeEnabled()) {
1596 this->DebugBuffer = cmStrCat(
1597 this->DebugBuffer, "The module is considered not found due to ",
1598 foundVar, " being FALSE.");
1599 }
1600

Callers 1

Calls 15

ReadListFileMethod · 0.95
DebugModeEnabledMethod · 0.80
IsDefinitionSetMethod · 0.80
emplace_backMethod · 0.80
FoundAtMethod · 0.80
cmStrCatFunction · 0.70
GetModulesFileMethod · 0.45
emptyMethod · 0.45
findMethod · 0.45
endMethod · 0.45
GetPolicyStatusMethod · 0.45
IssueMessageMethod · 0.45

Tested by

no test coverage detected