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

Method PushFindPackageRootPathStack

Source/cmFindPackageCommand.cxx:2349–2425  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2347}
2348
2349void cmFindPackageCommand::PushFindPackageRootPathStack()
2350{
2351 // Allocate a PACKAGE_ROOT_PATH for the current find_package call.
2352 this->Makefile->FindPackageRootPathStack.emplace_back();
2353 std::vector<std::string>& rootPaths =
2354 this->Makefile->FindPackageRootPathStack.back();
2355
2356 // Add root paths from <PackageName>_ROOT CMake and environment variables,
2357 // subject to CMP0074.
2358 std::string const rootVar = this->Name + "_ROOT";
2359 cmValue rootDef = this->Makefile->GetDefinition(rootVar);
2360 if (rootDef && rootDef.IsEmpty()) {
2361 rootDef = nullptr;
2362 }
2363 cm::optional<std::string> rootEnv = cmSystemTools::GetEnvVar(rootVar);
2364 if (rootEnv && rootEnv->empty()) {
2365 rootEnv = cm::nullopt;
2366 }
2367 switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0074)) {
2368 case cmPolicies::WARN:
2369 this->Makefile->MaybeWarnCMP0074(rootVar, rootDef, rootEnv);
2370 CM_FALLTHROUGH;
2371 case cmPolicies::OLD:
2372 // OLD behavior is to ignore the <PackageName>_ROOT variables.
2373 return;
2374 case cmPolicies::NEW: {
2375 // NEW behavior is to honor the <PackageName>_ROOT variables.
2376 } break;
2377 }
2378
2379 // Add root paths from <PACKAGENAME>_ROOT CMake and environment variables,
2380 // if they are different than <PackageName>_ROOT, and subject to CMP0144.
2381 std::string const rootVAR = cmSystemTools::UpperCase(rootVar);
2382 cmValue rootDEF;
2383 cm::optional<std::string> rootENV;
2384 if (rootVAR != rootVar) {
2385 rootDEF = this->Makefile->GetDefinition(rootVAR);
2386 if (rootDEF && (rootDEF.IsEmpty() || rootDEF == rootDef)) {
2387 rootDEF = nullptr;
2388 }
2389 rootENV = cmSystemTools::GetEnvVar(rootVAR);
2390 if (rootENV && (rootENV->empty() || rootENV == rootEnv)) {
2391 rootENV = cm::nullopt;
2392 }
2393 }
2394
2395 switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0144)) {
2396 case cmPolicies::WARN:
2397 this->Makefile->MaybeWarnCMP0144(rootVAR, rootDEF, rootENV);
2398 CM_FALLTHROUGH;
2399 case cmPolicies::OLD:
2400 // OLD behavior is to ignore the <PACKAGENAME>_ROOT variables.
2401 rootDEF = nullptr;
2402 rootENV = cm::nullopt;
2403 break;
2404 case cmPolicies::NEW: {
2405 // NEW behavior is to honor the <PACKAGENAME>_ROOT variables.
2406 } break;

Callers 1

PushPopRootPathStackMethod · 0.80

Calls 12

cmExpandListFunction · 0.85
moveFunction · 0.85
emplace_backMethod · 0.80
MaybeWarnCMP0074Method · 0.80
MaybeWarnCMP0144Method · 0.80
backMethod · 0.45
GetDefinitionMethod · 0.45
IsEmptyMethod · 0.45
emptyMethod · 0.45
GetPolicyStatusMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected