From e56108f629f0719429487b51ff952e80138949fa Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 18 Jul 2022 17:12:54 -0400 Subject: cmExecuteProcessCommand: Report keyword errors via argument parser results --- Source/cmExecuteProcessCommand.cxx | 12 ++++-------- Tests/RunCMake/execute_process/EchoCommand3-stderr.txt | 4 +++- Tests/RunCMake/execute_process/EncodingMissing-stderr.txt | 5 ++++- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Source/cmExecuteProcessCommand.cxx b/Source/cmExecuteProcessCommand.cxx index af56e2d..7fbd826 100644 --- a/Source/cmExecuteProcessCommand.cxx +++ b/Source/cmExecuteProcessCommand.cxx @@ -47,7 +47,7 @@ bool cmExecuteProcessCommand(std::vector const& args, return false; } - struct Arguments + struct Arguments : public ArgumentParser::ParseResult { std::vector> Commands; std::string OutputVariable; @@ -95,14 +95,10 @@ bool cmExecuteProcessCommand(std::vector const& args, .Bind("COMMAND_ERROR_IS_FATAL"_s, &Arguments::CommandErrorIsFatal); std::vector unparsedArguments; - std::vector keywordsMissingValue; - Arguments const arguments = - parser.Parse(args, &unparsedArguments, &keywordsMissingValue); + Arguments const arguments = parser.Parse(args, &unparsedArguments); - if (!keywordsMissingValue.empty()) { - status.SetError(cmStrCat(" called with no value for ", - keywordsMissingValue.front(), ".")); - return false; + if (arguments.MaybeReportError(status.GetMakefile())) { + return true; } if (!unparsedArguments.empty()) { status.SetError(" given unknown argument \"" + unparsedArguments.front() + diff --git a/Tests/RunCMake/execute_process/EchoCommand3-stderr.txt b/Tests/RunCMake/execute_process/EchoCommand3-stderr.txt index e27f1e6..62cad52 100644 --- a/Tests/RunCMake/execute_process/EchoCommand3-stderr.txt +++ b/Tests/RunCMake/execute_process/EchoCommand3-stderr.txt @@ -1,2 +1,4 @@ CMake Error at .*EchoCommand.cmake:.*\(execute_process\): - execute_process called with no value for COMMAND_ECHO. + Error after keyword "COMMAND_ECHO": + + missing required value diff --git a/Tests/RunCMake/execute_process/EncodingMissing-stderr.txt b/Tests/RunCMake/execute_process/EncodingMissing-stderr.txt index 1a69579..7f85654 100644 --- a/Tests/RunCMake/execute_process/EncodingMissing-stderr.txt +++ b/Tests/RunCMake/execute_process/EncodingMissing-stderr.txt @@ -1,4 +1,7 @@ ^CMake Error at EncodingMissing.cmake:[0-9]+ \(execute_process\): - execute_process called with no value for ENCODING. + Error after keyword "ENCODING": + + missing required value + Call Stack \(most recent call first\): CMakeLists.txt:[0-9]+ \(include\)$ -- cgit v0.12