diff options
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmCMakeLanguageCommand.cxx | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/Source/cmCMakeLanguageCommand.cxx b/Source/cmCMakeLanguageCommand.cxx index 329427c..9ffc363 100644 --- a/Source/cmCMakeLanguageCommand.cxx +++ b/Source/cmCMakeLanguageCommand.cxx @@ -398,6 +398,32 @@ bool cmCMakeLanguageCommand(std::vector<cmListFileArgument> const& args, if (!moreArgs()) { return FatalError(status, "called with incorrect number of arguments"); } + if (expArgs[expArg] == "EXIT"_s) { + ++expArg; // consume "EXIT". + + if (!moreArgs()) { + return FatalError(status, "EXIT requires one argument"); + } + + auto workingMode = + status.GetMakefile().GetCMakeInstance()->GetWorkingMode(); + if (workingMode != cmake::SCRIPT_MODE) { + return FatalError(status, "EXIT can be used only in SCRIPT mode"); + } + + long retCode = 0; + + if (!cmStrToLong(expArgs[expArg], &retCode)) { + return FatalError(status, + cmStrCat("EXIT requires one integral argument, got \"", + expArgs[expArg], '\"')); + } + + if (workingMode == cmake::SCRIPT_MODE) { + status.SetExitCode(static_cast<int>(retCode)); + } + return true; + } if (expArgs[expArg] == "SET_DEPENDENCY_PROVIDER"_s) { finishArgs(); |