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

Function cmIfCommand

Source/cmIfCommand.cxx:180–219  ·  view source on GitHub ↗

=========================================================================

Source from the content-addressed store, hash-verified

178
179//=========================================================================
180bool cmIfCommand(std::vector<cmListFileArgument> const& args,
181 cmExecutionStatus& inStatus)
182{
183 cmMakefile& makefile = inStatus.GetMakefile();
184 std::string errorString;
185
186 std::vector<cmExpandedCommandArgument> expandedArguments;
187 makefile.ExpandArguments(args, expandedArguments);
188
189 MessageType status;
190
191 cmConditionEvaluator conditionEvaluator(makefile, makefile.GetBacktrace());
192
193 bool isTrue =
194 conditionEvaluator.IsTrue(expandedArguments, errorString, status);
195
196 if (!errorString.empty()) {
197 std::string err =
198 cmStrCat("if ", cmIfCommandError(expandedArguments), errorString);
199 if (status == MessageType::FATAL_ERROR) {
200 makefile.IssueMessage(MessageType::FATAL_ERROR, err);
201 cmSystemTools::SetFatalErrorOccurred();
202 return true;
203 }
204 makefile.IssueMessage(status, err);
205 }
206
207 {
208 auto fb = cm::make_unique<cmIfFunctionBlocker>();
209 // if is isn't true block the commands
210 fb->IsBlocking = !isTrue;
211 if (isTrue) {
212 fb->HasRun = true;
213 }
214 fb->Args = args;
215 makefile.AddFunctionBlocker(std::move(fb));
216 }
217
218 return true;
219}

Callers

nothing calls this directly

Calls 10

cmIfCommandErrorFunction · 0.85
moveFunction · 0.85
ExpandArgumentsMethod · 0.80
IsTrueMethod · 0.80
AddFunctionBlockerMethod · 0.80
cmStrCatFunction · 0.70
GetMakefileMethod · 0.45
GetBacktraceMethod · 0.45
emptyMethod · 0.45
IssueMessageMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…