| 363 | } |
| 364 | |
| 365 | bool cmCMakeLanguageCommand(std::vector<cmListFileArgument> const& args, |
| 366 | cmExecutionStatus& status) |
| 367 | { |
| 368 | std::vector<std::string> expArgs; |
| 369 | size_t rawArg = 0; |
| 370 | size_t expArg = 0; |
| 371 | |
| 372 | // Helper to consume and expand one raw argument at a time. |
| 373 | auto moreArgs = [&]() -> bool { |
| 374 | while (expArg >= expArgs.size()) { |
| 375 | if (rawArg >= args.size()) { |
| 376 | return false; |
| 377 | } |
| 378 | std::vector<cmListFileArgument> tmpArg; |
| 379 | tmpArg.emplace_back(args[rawArg++]); |
| 380 | status.GetMakefile().ExpandArguments(tmpArg, expArgs); |
| 381 | } |
| 382 | return true; |
| 383 | }; |
| 384 | auto finishArgs = [&]() { |
| 385 | std::vector<cmListFileArgument> tmpArgs(args.begin() + rawArg, args.end()); |
| 386 | status.GetMakefile().ExpandArguments(tmpArgs, expArgs); |
| 387 | rawArg = args.size(); |
| 388 | }; |
| 389 | |
| 390 | if (!moreArgs()) { |
| 391 | return FatalError(status, "called with incorrect number of arguments"); |
| 392 | } |
| 393 | if (expArgs[expArg] == "EXIT"_s) { |
| 394 | ++expArg; // consume "EXIT". |
| 395 | |
| 396 | if (!moreArgs()) { |
| 397 | return FatalError(status, "EXIT requires one argument"); |
| 398 | } |
| 399 | |
| 400 | if (!status.GetMakefile().GetCMakeInstance()->RoleSupportsExitCode()) { |
| 401 | return FatalError(status, "EXIT can be used only in SCRIPT mode"); |
| 402 | } |
| 403 | |
| 404 | long retCode = 0; |
| 405 | |
| 406 | if (!cmStrToLong(expArgs[expArg], &retCode)) { |
| 407 | return FatalError(status, |
| 408 | cmStrCat("EXIT requires one integral argument, got \"", |
| 409 | expArgs[expArg], '\"')); |
| 410 | } |
| 411 | |
| 412 | status.SetExitCode(static_cast<int>(retCode)); |
| 413 | return true; |
| 414 | } |
| 415 | |
| 416 | if (expArgs[expArg] == "SET_DEPENDENCY_PROVIDER"_s) { |
| 417 | finishArgs(); |
| 418 | return cmCMakeLanguageCommandSET_DEPENDENCY_PROVIDER(expArgs, status); |
| 419 | } |
| 420 | |
| 421 | cm::optional<Defer> maybeDefer; |
| 422 | if (expArgs[expArg] == "DEFER"_s) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…