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

Function cmCMakeLanguageCommandDEFER

Source/cmCMakeLanguageCommand.cxx:119–196  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

117}
118
119bool cmCMakeLanguageCommandDEFER(Defer const& defer,
120 std::vector<std::string> const& args,
121 size_t arg, cmExecutionStatus& status)
122{
123 cmMakefile* deferMakefile =
124 defer.Directory ? defer.Directory : &status.GetMakefile();
125 if (args[arg] == "CANCEL_CALL"_s) {
126 ++arg; // Consume CANCEL_CALL.
127 auto ids = cmMakeRange(args).advance(arg);
128 for (std::string const& id : ids) {
129 if (id[0] >= 'A' && id[0] <= 'Z') {
130 return FatalError(
131 status, cmStrCat("DEFER CANCEL_CALL unknown argument:\n "_s, id));
132 }
133 if (!deferMakefile->DeferCancelCall(id)) {
134 return FatalError(
135 status,
136 cmStrCat("DEFER CANCEL_CALL may not update directory:\n "_s,
137 deferMakefile->GetCurrentBinaryDirectory(),
138 "\nat this time."_s));
139 }
140 }
141 return true;
142 }
143 if (args[arg] == "GET_CALL_IDS"_s) {
144 ++arg; // Consume GET_CALL_IDS.
145 if (arg == args.size()) {
146 return FatalError(status, "DEFER GET_CALL_IDS missing output variable");
147 }
148 std::string const& var = args[arg++];
149 if (arg != args.size()) {
150 return FatalError(status, "DEFER GET_CALL_IDS given too many arguments");
151 }
152 cm::optional<std::string> ids = deferMakefile->DeferGetCallIds();
153 if (!ids) {
154 return FatalError(
155 status,
156 cmStrCat("DEFER GET_CALL_IDS may not access directory:\n "_s,
157 deferMakefile->GetCurrentBinaryDirectory(),
158 "\nat this time."_s));
159 }
160 status.GetMakefile().AddDefinition(var, *ids);
161 return true;
162 }
163 if (args[arg] == "GET_CALL"_s) {
164 ++arg; // Consume GET_CALL.
165 if (arg == args.size()) {
166 return FatalError(status, "DEFER GET_CALL missing id");
167 }
168 std::string const& id = args[arg++];
169 if (arg == args.size()) {
170 return FatalError(status, "DEFER GET_CALL missing output variable");
171 }
172 std::string const& var = args[arg++];
173 if (arg != args.size()) {
174 return FatalError(status, "DEFER GET_CALL given too many arguments");
175 }
176 if (id.empty()) {

Callers 1

cmCMakeLanguageCommandFunction · 0.85

Calls 11

cmMakeRangeFunction · 0.85
FatalErrorFunction · 0.85
DeferCancelCallMethod · 0.80
DeferGetCallIdsMethod · 0.80
DeferGetCallMethod · 0.80
cmStrCatFunction · 0.70
GetMakefileMethod · 0.45
advanceMethod · 0.45
sizeMethod · 0.45
AddDefinitionMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…