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

Method ImportPackageTargets

Source/cmFindPackageCommand.cxx:2233–2273  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2231}
2232
2233bool cmFindPackageCommand::ImportPackageTargets(cmPackageState& packageState,
2234 std::string const& filePath,
2235 cmPackageInfoReader& reader)
2236{
2237 // Check if we've already imported this file.
2238 std::string fileName = cmSystemTools::GetFilenameName(filePath);
2239 if (cm::contains(packageState.ImportedFiles, fileName)) {
2240 return true;
2241 }
2242
2243 // Import base file.
2244 if (!reader.ImportTargets(this->Makefile, this->Status, this->GlobalScope)) {
2245 return false;
2246 }
2247
2248 // Find supplemental configuration files.
2249 cmsys::Glob glob;
2250 glob.RecurseOff();
2251 if (glob.FindFiles(
2252 cmStrCat(cmSystemTools::GetFilenamePath(filePath), '/',
2253 cmSystemTools::GetFilenameWithoutExtension(filePath),
2254 "@*.[Cc][Pp][Ss]"_s))) {
2255
2256 // Try to read supplemental data from each file found.
2257 for (std::string const& extra : glob.GetFiles()) {
2258 cmMakefile::CallRAII cs{ this->Makefile, extra, this->Status };
2259
2260 std::unique_ptr<cmPackageInfoReader> configReader =
2261 cmPackageInfoReader::Read(this->Makefile, extra, &reader);
2262 if (configReader && configReader->GetName() == this->Name) {
2263 if (!configReader->ImportTargetConfigurations(this->Makefile,
2264 this->Status)) {
2265 return false;
2266 }
2267 }
2268 }
2269 }
2270
2271 packageState.ImportedFiles.emplace(std::move(fileName));
2272 return true;
2273}
2274
2275void cmFindPackageCommand::AppendToFoundProperty(bool const found)
2276{

Callers 1

ReadPackageMethod · 0.95

Calls 8

moveFunction · 0.85
ImportTargetsMethod · 0.80
FindFilesMethod · 0.80
emplaceMethod · 0.80
cmStrCatFunction · 0.70
GetFilesMethod · 0.45
GetNameMethod · 0.45

Tested by

no test coverage detected