diff options
author | Brad King <brad.king@kitware.com> | 2022-12-12 18:05:53 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2022-12-14 16:42:29 (GMT) |
commit | 8d29a0bda616c4c344def2b1db7aaa94b7f27dbb (patch) | |
tree | 938526cc15f85f14ef4141868f40bfbed377d4bc /Source/cmTryRunCommand.cxx | |
parent | fdda4095a32dcbb9cc0e9b38067652c025447822 (diff) | |
download | CMake-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.cxx | 22 |
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 |