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

Function HandleGetMode

Source/cmCMakePolicyCommand.cxx:91–135  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

89}
90
91bool HandleGetMode(std::vector<std::string> const& args,
92 cmExecutionStatus& status)
93{
94 bool parent_scope = false;
95 if (args.size() == 4 && args[3] == "PARENT_SCOPE") {
96 // Undocumented PARENT_SCOPE option for use within CMake.
97 parent_scope = true;
98 } else if (args.size() != 3) {
99 status.SetError("GET must be given exactly 2 additional arguments.");
100 return false;
101 }
102
103 // Get arguments.
104 std::string const& id = args[1];
105 std::string const& var = args[2];
106
107 // Lookup the policy number.
108 cmPolicies::PolicyID pid;
109 if (!cmPolicies::GetPolicyID(id.c_str(), pid)) {
110 status.SetError(
111 cmStrCat("GET given policy \"", id,
112 "\" which is not known to this version of CMake."));
113 return false;
114 }
115
116 // Lookup the policy setting.
117 cmPolicies::PolicyStatus policyStatus =
118 status.GetMakefile().GetPolicyStatus(pid, parent_scope);
119 switch (policyStatus) {
120 case cmPolicies::OLD:
121 // Report that the policy is set to OLD.
122 status.GetMakefile().AddDefinition(var, "OLD");
123 break;
124 case cmPolicies::WARN:
125 // Report that the policy is not set.
126 status.GetMakefile().AddDefinition(var, "");
127 break;
128 case cmPolicies::NEW:
129 // Report that the policy is set to NEW.
130 status.GetMakefile().AddDefinition(var, "NEW");
131 break;
132 }
133
134 return true;
135}
136
137bool HandleVersionMode(std::vector<std::string> const& args,
138 cmExecutionStatus& status)

Callers 1

cmCMakePolicyCommandFunction · 0.85

Calls 7

c_strMethod · 0.80
cmStrCatFunction · 0.70
sizeMethod · 0.45
SetErrorMethod · 0.45
GetPolicyStatusMethod · 0.45
GetMakefileMethod · 0.45
AddDefinitionMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…