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

Function HandleInMode

Source/cmForEachCommand.cxx:291–382  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

289}
290
291bool HandleInMode(std::vector<std::string> const& args,
292 std::vector<std::string>::const_iterator kwInIter,
293 cmMakefile& makefile)
294{
295 assert("A valid iterator expected" && kwInIter != args.end());
296
297 auto fb = cm::make_unique<cmForEachFunctionBlocker>(&makefile);
298
299 // Copy iteration variable names first
300 std::copy(args.begin(), kwInIter, std::back_inserter(fb->Args));
301 // Remember the count of given iteration variable names
302 auto const varsCount = fb->Args.size();
303 fb->SetIterationVarsCount(varsCount);
304
305 enum Doing
306 {
307 DoingNone,
308 DoingLists,
309 DoingItems,
310 DoingZipLists
311 };
312 Doing doing = DoingNone;
313 // Iterate over arguments past the "IN" keyword
314 for (std::string const& arg : cmMakeRange(++kwInIter, args.end())) {
315 if (arg == "LISTS") {
316 if (doing == DoingZipLists) {
317 makefile.IssueMessage(MessageType::FATAL_ERROR,
318 "ZIP_LISTS can not be used with LISTS or ITEMS");
319 return true;
320 }
321 if (varsCount != 1u) {
322 makefile.IssueMessage(
323 MessageType::FATAL_ERROR,
324 "ITEMS or LISTS require exactly one iteration variable");
325 return true;
326 }
327 doing = DoingLists;
328
329 } else if (arg == "ITEMS") {
330 if (doing == DoingZipLists) {
331 makefile.IssueMessage(MessageType::FATAL_ERROR,
332 "ZIP_LISTS can not be used with LISTS or ITEMS");
333 return true;
334 }
335 if (varsCount != 1u) {
336 makefile.IssueMessage(
337 MessageType::FATAL_ERROR,
338 "ITEMS or LISTS require exactly one iteration variable");
339 return true;
340 }
341 doing = DoingItems;
342
343 } else if (arg == "ZIP_LISTS") {
344 if (doing != DoingNone) {
345 makefile.IssueMessage(MessageType::FATAL_ERROR,
346 "ZIP_LISTS can not be used with LISTS or ITEMS");
347 return true;
348 }

Callers 1

cmForEachCommandFunction · 0.85

Calls 13

cmMakeRangeFunction · 0.85
cmExpandListFunction · 0.85
moveFunction · 0.85
SetIterationVarsCountMethod · 0.80
SetZipListsMethod · 0.80
push_backMethod · 0.80
AddFunctionBlockerMethod · 0.80
cmStrCatFunction · 0.70
endMethod · 0.45
beginMethod · 0.45
sizeMethod · 0.45
IssueMessageMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…