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

Method SearchPrefix

Source/cmFindPackageCommand.cxx:3284–3450  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3282}
3283
3284bool cmFindPackageCommand::SearchPrefix(std::string const& prefix)
3285{
3286 assert(!prefix.empty() && prefix.back() == '/');
3287
3288 // Skip this if the prefix does not exist.
3289 if (!cmSystemTools::FileIsDirectory(prefix)) {
3290 return false;
3291 }
3292
3293 // Skip this if it's in ignored paths.
3294 std::string prefixWithoutSlash = prefix;
3295 if (prefixWithoutSlash != "/" && prefixWithoutSlash.back() == '/') {
3296 prefixWithoutSlash.erase(prefixWithoutSlash.length() - 1);
3297 }
3298 if (this->IgnoredPaths.count(prefixWithoutSlash) ||
3299 this->IgnoredPrefixPaths.count(prefixWithoutSlash)) {
3300 return false;
3301 }
3302
3303 auto searchFn = [this](std::string const& fullPath,
3304 PackageDescriptionType type) -> bool {
3305 return this->SearchDirectory(fullPath, type);
3306 };
3307
3308 auto iCpsGen = cmCaseInsensitiveDirectoryListGenerator{ "cps"_s };
3309 auto iCMakeGen = cmCaseInsensitiveDirectoryListGenerator{ "cmake"_s };
3310 auto anyDirGen =
3311 cmAnyDirectoryListGenerator{ this->SortOrder, this->SortDirection };
3312 auto cpsPkgDirGen =
3313 cmProjectDirectoryListGenerator{ &this->Names, this->SortOrder,
3314 this->SortDirection, true };
3315 auto cmakePkgDirGen =
3316 cmProjectDirectoryListGenerator{ &this->Names, this->SortOrder,
3317 this->SortDirection, false };
3318
3319 // PREFIX/(Foo|foo|FOO)/(cps|CPS)/
3320 if (TryGeneratedPaths(searchFn, pdt::Cps, prefix, cpsPkgDirGen, iCpsGen)) {
3321 return true;
3322 }
3323
3324 // PREFIX/(Foo|foo|FOO)/*/(cps|CPS)/
3325 if (TryGeneratedPaths(searchFn, pdt::Cps, prefix, cpsPkgDirGen, iCpsGen,
3326 anyDirGen)) {
3327 return true;
3328 }
3329
3330 // PREFIX/(cps|CPS)/(Foo|foo|FOO)/
3331 if (TryGeneratedPaths(searchFn, pdt::Cps, prefix, iCpsGen, cpsPkgDirGen)) {
3332 return true;
3333 }
3334
3335 // PREFIX/(cps|CPS)/(Foo|foo|FOO)/*/
3336 if (TryGeneratedPaths(searchFn, pdt::Cps, prefix, iCpsGen, cpsPkgDirGen,
3337 anyDirGen)) {
3338 return true;
3339 }
3340
3341 // PREFIX/(cps|CPS)/ (useful on windows or in build trees)

Callers 1

FindPrefixedConfigMethod · 0.95

Calls 8

SearchDirectoryMethod · 0.95
TryGeneratedPathsFunction · 0.85
eraseMethod · 0.80
lengthMethod · 0.80
emplace_backMethod · 0.80
emptyMethod · 0.45
backMethod · 0.45
countMethod · 0.45

Tested by

no test coverage detected