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

Method SetCacheArgs

Source/cmake.cxx:573–783  ·  view source on GitHub ↗

Parse the args

Source from the content-addressed store, hash-verified

571
572// Parse the args
573bool cmake::SetCacheArgs(std::vector<std::string> const& args)
574{
575 static std::string const kCMAKE_POLICY_VERSION_MINIMUM =
576 "CMAKE_POLICY_VERSION_MINIMUM";
577 if (!this->State->GetInitializedCacheValue(kCMAKE_POLICY_VERSION_MINIMUM)) {
578 cm::optional<std::string> policyVersion =
579 cmSystemTools::GetEnvVar(kCMAKE_POLICY_VERSION_MINIMUM);
580 if (policyVersion && !policyVersion->empty()) {
581 this->AddCacheEntry(
582 kCMAKE_POLICY_VERSION_MINIMUM, *policyVersion,
583 "Override policy version for cmake_minimum_required calls.",
584 cmStateEnums::STRING);
585 this->State->SetCacheEntryProperty(kCMAKE_POLICY_VERSION_MINIMUM,
586 "ADVANCED", "1");
587 }
588 }
589
590 auto DefineLambda = [](std::string const& entry, cmake* state) -> bool {
591 std::string var;
592 std::string value;
593 cmStateEnums::CacheEntryType type = cmStateEnums::UNINITIALIZED;
594 if (cmState::ParseCacheEntry(entry, var, value, type)) {
595#ifndef CMAKE_BOOTSTRAP
596 state->UnprocessedPresetVariables.erase(var);
597#endif
598 state->ProcessCacheArg(var, value, type);
599 } else {
600 cmSystemTools::Error(cmStrCat("Parse error in command line argument: ",
601 entry, "\n Should be: VAR:type=value\n"));
602 return false;
603 }
604 return true;
605 };
606
607 auto WarningLambda = [](cm::string_view entry, cmake* state) -> bool {
608 bool foundNo = false;
609 bool foundError = false;
610
611 if (cmHasLiteralPrefix(entry, "no-")) {
612 foundNo = true;
613 entry.remove_prefix(3);
614 }
615
616 if (cmHasLiteralPrefix(entry, "error=")) {
617 foundError = true;
618 entry.remove_prefix(6);
619 }
620
621 if (entry.empty()) {
622 cmSystemTools::Error("No warning name provided.");
623 return false;
624 }
625
626 std::string const name = std::string(entry);
627 if (!foundNo && !foundError) {
628 // -W<name>
629 state->DiagLevels[name] = std::max(state->DiagLevels[name], DIAG_WARN);
630 } else if (foundNo && !foundError) {

Callers 4

RunMethod · 0.95
TryCompileMethod · 0.80
do_cmakeFunction · 0.80
LoadCacheMethod · 0.80

Calls 15

AddCacheEntryMethod · 0.95
FindPackageMethod · 0.95
cmHasLiteralPrefixFunction · 0.85
minFunction · 0.85
eraseMethod · 0.80
ProcessCacheArgMethod · 0.80
push_backMethod · 0.80
GetRoleMethod · 0.80
SetHomeDirectoryMethod · 0.80

Tested by

no test coverage detected