mirror of
https://github.com/Kitware/CMake.git
synced 2026-04-25 07:38:33 -05:00
cmake: Report if the <LANG>_CLANG_TIDY tool exits with non-zero
When using `<LANG>_CLANG_TIDY` our internal launcher for the tool must capture its return code and stderr and report them on failure. Otherwise incorrect command lines silently fail. Closes: #16435
This commit is contained in:
+10
-3
@@ -358,14 +358,21 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
|
||||
|
||||
// Run the tidy command line. Capture its stdout and hide its stderr.
|
||||
std::string stdOut;
|
||||
if (!cmSystemTools::RunSingleCommand(tidy_cmd, &stdOut, CM_NULLPTR,
|
||||
&ret, CM_NULLPTR,
|
||||
std::string stdErr;
|
||||
if (!cmSystemTools::RunSingleCommand(tidy_cmd, &stdOut, &stdErr, &ret,
|
||||
CM_NULLPTR,
|
||||
cmSystemTools::OUTPUT_NONE)) {
|
||||
std::cerr << "Error running '" << tidy_cmd[0] << "'\n";
|
||||
std::cerr << "Error running '" << tidy_cmd[0] << "': " << stdErr
|
||||
<< "\n";
|
||||
return 1;
|
||||
}
|
||||
// Output the stdout from clang-tidy to stderr
|
||||
std::cerr << stdOut;
|
||||
// If clang-tidy exited with an error do the same.
|
||||
if (ret != 0) {
|
||||
std::cerr << stdErr;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
if (!lwyu.empty()) {
|
||||
// Construct the ldd -r -u (link what you use lwyu) command line
|
||||
|
||||
Reference in New Issue
Block a user