MCPcopy Index your code
hub / github.com/Kitware/CMake / HandlePackageMode

Method HandlePackageMode

Source/cmFindPackageCommand.cxx:1626–1924  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1624}
1625
1626bool cmFindPackageCommand::HandlePackageMode(
1627 HandlePackageModeType const handlePackageModeType)
1628{
1629 this->ConsideredConfigs.clear();
1630
1631 // Try to find the config file.
1632 cmValue def = this->Makefile->GetDefinition(this->Variable);
1633
1634 // Try to load the config file if the directory is known
1635 bool fileFound = false;
1636 if (this->UseConfigFiles) {
1637 if (!def.IsOff()) {
1638 // Get the directory from the variable value.
1639 std::string dir = *def;
1640 cmSystemTools::ConvertToUnixSlashes(dir);
1641
1642 // Treat relative paths with respect to the current source dir.
1643 if (!cmSystemTools::FileIsFullPath(dir)) {
1644 dir = "/" + dir;
1645 dir = this->Makefile->GetCurrentSourceDirectory() + dir;
1646 }
1647 // The file location was cached. Look for the correct file.
1648 std::string file;
1649 FoundPackageMode foundMode = FoundPackageMode::None;
1650 if (this->FindConfigFile(dir, pdt::Any, file, foundMode)) {
1651 if (this->DebugState) {
1652 this->DebugState->FoundAt(file);
1653 }
1654 this->FileFound = std::move(file);
1655 this->FileFoundMode = foundMode;
1656 fileFound = true;
1657 }
1658 def = this->Makefile->GetDefinition(this->Variable);
1659 }
1660
1661 // Search for the config file if it is not already found.
1662 if (def.IsOff() || !fileFound) {
1663 fileFound = this->FindConfig();
1664 }
1665
1666 // Sanity check.
1667 if (fileFound && this->FileFound.empty()) {
1668 this->Makefile->IssueMessage(
1669 MessageType::INTERNAL_ERROR,
1670 "fileFound is true but FileFound is empty!");
1671 fileFound = false;
1672 }
1673 }
1674
1675 std::string const foundVar = cmStrCat(this->Name, "_FOUND");
1676 std::string const notFoundMessageVar =
1677 cmStrCat(this->Name, "_NOT_FOUND_MESSAGE");
1678 std::string notFoundMessage;
1679
1680 // If the directory for the config file was found, try to read the file.
1681 bool result = true;
1682 bool found = false;
1683 bool configFileSetFOUNDFalse = false;

Callers 2

FindPackageMethod · 0.95

Calls 15

FindConfigFileMethod · 0.95
FindConfigMethod · 0.95
StoreVersionFoundMethod · 0.95
ReadPackageMethod · 0.95
ReadListFileMethod · 0.95
IsRequiredMethod · 0.95
moveFunction · 0.85
cmMakeRangeFunction · 0.85
cmRemoveDuplicatesFunction · 0.85
cmWrapFunction · 0.85
FoundAtMethod · 0.80
IsDefinitionSetMethod · 0.80

Tested by

no test coverage detected