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

Method ReadPackage

Source/cmFindPackageCommand.cxx:2106–2188  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2104}
2105
2106bool cmFindPackageCommand::ReadPackage()
2107{
2108 // Resolve any transitive dependencies for the root file.
2109 if (!FindPackageDependencies(this->FileFound, *this->CpsReader,
2110 this->Required)) {
2111 return false;
2112 }
2113
2114 bool const hasComponentsRequested =
2115 !this->RequiredComponents.empty() || !this->OptionalComponents.empty();
2116
2117 cmMakefile::CallRAII cs{ this->Makefile, this->FileFound, this->Status };
2118 cmMakefile::PolicyPushPop ps{ this->Makefile };
2119
2120 this->Makefile->SetPolicy(cmPolicies::CMP0200, cmPolicies::NEW);
2121
2122 // Loop over appendices.
2123 auto iter = this->CpsAppendices.begin();
2124 while (iter != this->CpsAppendices.end()) {
2125 RequiredStatus required = RequiredStatus::Optional;
2126 bool important = false;
2127
2128 // Check if this appendix provides any requested components.
2129 if (hasComponentsRequested) {
2130 auto providesAny = [&iter](
2131 std::set<std::string> const& desiredComponents) {
2132 return std::any_of(iter->second.Components.begin(),
2133 iter->second.Components.end(),
2134 [&desiredComponents](std::string const& component) {
2135 return cm::contains(desiredComponents, component);
2136 });
2137 };
2138
2139 if (providesAny(this->RequiredComponents)) {
2140 important = true;
2141 required = this->Required;
2142 } else if (!providesAny(this->OptionalComponents)) {
2143 // This appendix doesn't provide any requested components; remove it
2144 // from the set to be imported.
2145 iter = this->CpsAppendices.erase(iter);
2146 continue;
2147 }
2148 }
2149
2150 // Resolve any transitive dependencies for the appendix.
2151 if (!this->FindPackageDependencies(iter->first, iter->second, required)) {
2152 if (important) {
2153 // Some dependencies are missing, and we need(ed) this appendix; fail.
2154 return false;
2155 }
2156
2157 // Some dependencies are missing, but we don't need this appendix; remove
2158 // it from the set to be imported.
2159 iter = this->CpsAppendices.erase(iter);
2160 } else {
2161 ++iter;
2162 }
2163 }

Callers 1

HandlePackageModeMethod · 0.95

Calls 8

ImportPackageTargetsMethod · 0.95
eraseMethod · 0.80
emptyMethod · 0.45
SetPolicyMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
GetStateSnapshotMethod · 0.45

Tested by

no test coverage detected