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

Function cmForEachCommand

Source/cmForEachCommand.cxx:403–490  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

401} // anonymous namespace
402
403bool cmForEachCommand(std::vector<std::string> const& args,
404 cmExecutionStatus& status)
405{
406 if (args.empty()) {
407 status.SetError("called with incorrect number of arguments");
408 return false;
409 }
410 auto kwInIter = std::find(args.begin(), args.end(), "IN");
411 if (kwInIter != args.end()) {
412 return HandleInMode(args, kwInIter, status.GetMakefile());
413 }
414
415 // create a function blocker
416 auto fb = cm::make_unique<cmForEachFunctionBlocker>(&status.GetMakefile());
417 if (args.size() > 1) {
418 if (args[1] == "RANGE") {
419 int start = 0;
420 int stop = 0;
421 int step = 0;
422 if (args.size() == 3) {
423 if (!TryParseInteger(status, args[2], stop)) {
424 return false;
425 }
426 }
427 if (args.size() == 4) {
428 if (!TryParseInteger(status, args[2], start)) {
429 return false;
430 }
431 if (!TryParseInteger(status, args[3], stop)) {
432 return false;
433 }
434 }
435 if (args.size() == 5) {
436 if (!TryParseInteger(status, args[2], start)) {
437 return false;
438 }
439 if (!TryParseInteger(status, args[3], stop)) {
440 return false;
441 }
442 if (!TryParseInteger(status, args[4], step)) {
443 return false;
444 }
445 }
446 if (step == 0) {
447 if (start > stop) {
448 step = -1;
449 } else {
450 step = 1;
451 }
452 }
453 if ((start > stop && step > 0) || (start < stop && step < 0) ||
454 step == 0) {
455 status.SetError(
456 cmStrCat("called with incorrect range specification: start ", start,
457 ", stop ", stop, ", step ", step));
458 cmSystemTools::SetFatalErrorOccurred();
459 return false;
460 }

Callers

nothing calls this directly

Calls 15

HandleInModeFunction · 0.85
TryParseIntegerFunction · 0.85
to_stringFunction · 0.85
moveFunction · 0.85
SetIterationVarsCountMethod · 0.80
AddFunctionBlockerMethod · 0.80
cmStrCatFunction · 0.70
findFunction · 0.50
emptyMethod · 0.45
SetErrorMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…