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

Method Replay

Source/cmIfCommand.cxx:60–177  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58}
59
60bool cmIfFunctionBlocker::Replay(std::vector<cmListFileFunction> functions,
61 cmExecutionStatus& inStatus)
62{
63 cmMakefile& mf = inStatus.GetMakefile();
64 // execute the functions for the true parts of the if statement
65 int scopeDepth = 0;
66 for (cmListFileFunction const& func : functions) {
67 // keep track of scope depth
68 if (func.LowerCaseName() == "if") {
69 scopeDepth++;
70 }
71 if (func.LowerCaseName() == "endif") {
72 scopeDepth--;
73 }
74 // watch for our state change
75 if (scopeDepth == 0 && func.LowerCaseName() == "else") {
76 cmListFileBacktrace elseBT = mf.GetBacktrace().Push(
77 cmListFileContext{ func.OriginalName(),
78 this->GetStartingContext().FilePath, func.Line() });
79
80 if (this->ElseSeen) {
81 mf.GetCMakeInstance()->IssueMessage(
82 MessageType::FATAL_ERROR,
83 "A duplicate ELSE command was found inside an IF block.", elseBT);
84 cmSystemTools::SetFatalErrorOccurred();
85 return true;
86 }
87
88 this->IsBlocking = this->HasRun;
89 this->HasRun = true;
90 this->ElseSeen = true;
91
92 // if trace is enabled, print a (trivially) evaluated "else"
93 // statement
94 if (!this->IsBlocking && mf.GetCMakeInstance()->GetTrace()) {
95 mf.PrintCommandTrace(func, elseBT,
96 cmMakefile::CommandMissingFromStack::Yes);
97 }
98 } else if (scopeDepth == 0 && func.LowerCaseName() == "elseif") {
99 cmListFileBacktrace elseifBT = mf.GetBacktrace().Push(
100 cmListFileContext{ func.OriginalName(),
101 this->GetStartingContext().FilePath, func.Line() });
102 if (this->ElseSeen) {
103 mf.GetCMakeInstance()->IssueMessage(
104 MessageType::FATAL_ERROR,
105 "An ELSEIF command was found after an ELSE command.", elseifBT);
106 cmSystemTools::SetFatalErrorOccurred();
107 return true;
108 }
109
110 if (func.Arguments().empty()) {
111 mf.GetCMakeInstance()->IssueMessage(
112 MessageType::AUTHOR_WARNING,
113 "ELSEIF called with no arguments, it will be skipped. ", elseifBT);
114 }
115
116 if (this->HasRun) {
117 this->IsBlocking = true;

Callers 1

IsFunctionBlockedMethod · 0.45

Calls 15

cmIfCommandErrorFunction · 0.85
PushMethod · 0.80
LineMethod · 0.80
GetTraceMethod · 0.80
PrintCommandTraceMethod · 0.80
ArgumentsMethod · 0.80
ExpandArgumentsMethod · 0.80
IsTrueMethod · 0.80
ExecuteCommandMethod · 0.80
GetReturnInvokedMethod · 0.80
SetReturnInvokedMethod · 0.80
GetBreakInvokedMethod · 0.80

Tested by

no test coverage detected