summaryrefslogtreecommitdiffstats
path: root/Source/cmTryRunCommand.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-12-12 18:05:53 (GMT)
committerBrad King <brad.king@kitware.com>2022-12-14 16:42:29 (GMT)
commit8d29a0bda616c4c344def2b1db7aaa94b7f27dbb (patch)
tree938526cc15f85f14ef4141868f40bfbed377d4bc /Source/cmTryRunCommand.cxx
parentfdda4095a32dcbb9cc0e9b38067652c025447822 (diff)
downloadCMake-8d29a0bda616c4c344def2b1db7aaa94b7f27dbb.zip
CMake-8d29a0bda616c4c344def2b1db7aaa94b7f27dbb.tar.gz
CMake-8d29a0bda616c4c344def2b1db7aaa94b7f27dbb.tar.bz2
cmTryRunCommand: Factor out stdout/stderr capture conditions
Diffstat (limited to 'Source/cmTryRunCommand.cxx')
-rw-r--r--Source/cmTryRunCommand.cxx22
1 files changed, 8 insertions, 14 deletions
diff --git a/Source/cmTryRunCommand.cxx b/Source/cmTryRunCommand.cxx
index 1b545d5..bbefcd9 100644
--- a/Source/cmTryRunCommand.cxx
+++ b/Source/cmTryRunCommand.cxx
@@ -96,14 +96,16 @@ bool TryRunCommandImpl::TryRunCode(std::vector<std::string> const& argv)
}
bool captureRunOutput = false;
- bool captureRunOutputStdOutErr = false;
+ bool captureRunOutputStdOut = false;
+ bool captureRunOutputStdErr = false;
if (arguments.OutputVariable) {
captureRunOutput = true;
} else if (arguments.CompileOutputVariable) {
arguments.OutputVariable = arguments.CompileOutputVariable;
}
if (arguments.RunOutputStdOutVariable || arguments.RunOutputStdErrVariable) {
- captureRunOutputStdOutErr = true;
+ captureRunOutputStdOut = arguments.RunOutputStdOutVariable.has_value();
+ captureRunOutputStdErr = arguments.RunOutputStdErrVariable.has_value();
} else if (arguments.RunOutputVariable) {
captureRunOutput = true;
}
@@ -132,22 +134,14 @@ bool TryRunCommandImpl::TryRunCode(std::vector<std::string> const& argv)
runArgs, *arguments.SourceDirectoryOrFile,
*arguments.CompileResultVariable,
captureRunOutput ? &runOutputContents : nullptr,
- captureRunOutputStdOutErr && arguments.RunOutputStdOutVariable
- ? &runOutputStdOutContents
- : nullptr,
- captureRunOutputStdOutErr && arguments.RunOutputStdErrVariable
- ? &runOutputStdErrContents
- : nullptr);
+ captureRunOutputStdOut ? &runOutputStdOutContents : nullptr,
+ captureRunOutputStdErr ? &runOutputStdErrContents : nullptr);
} else {
this->RunExecutable(
runArgs, arguments.RunWorkingDirectory,
captureRunOutput ? &runOutputContents : nullptr,
- captureRunOutputStdOutErr && arguments.RunOutputStdOutVariable
- ? &runOutputStdOutContents
- : nullptr,
- captureRunOutputStdOutErr && arguments.RunOutputStdErrVariable
- ? &runOutputStdErrContents
- : nullptr);
+ captureRunOutputStdOut ? &runOutputStdOutContents : nullptr,
+ captureRunOutputStdErr ? &runOutputStdErrContents : nullptr);
}
// now put the output into the variables