summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-01-12 18:53:54 (GMT)
committerBrad King <brad.king@kitware.com>2023-01-12 18:55:52 (GMT)
commit0191e8b512d4a2d2bdb9f65ea9edebced9dee372 (patch)
treee96858b84fa529aa443829e0c4cfc02f5a98c40c
parente4c281e45196b3c3fa2f327476838ac77b76e838 (diff)
downloadCMake-0191e8b512d4a2d2bdb9f65ea9edebced9dee372.zip
CMake-0191e8b512d4a2d2bdb9f65ea9edebced9dee372.tar.gz
CMake-0191e8b512d4a2d2bdb9f65ea9edebced9dee372.tar.bz2
try_run: Do not require unrequested stdout/stderr when cross-compiling
Since commit 048a02d5bb (ConfigureLog: Log try_compile and try_run checks, 2022-11-23) we always capture the stdout/stderr for logging. When cross-compiling, do not require `__TRYRUN_OUTPUT_STD{OUT,ERR}` variables to be populated just for the logging.
-rw-r--r--Source/cmTryRunCommand.cxx14
1 files changed, 10 insertions, 4 deletions
diff --git a/Source/cmTryRunCommand.cxx b/Source/cmTryRunCommand.cxx
index 86c9679..dcb52da 100644
--- a/Source/cmTryRunCommand.cxx
+++ b/Source/cmTryRunCommand.cxx
@@ -90,7 +90,8 @@ public:
std::string const& compileResultVariable,
std::string* runOutputContents,
std::string* runOutputStdOutContents,
- std::string* runOutputStdErrContents);
+ std::string* runOutputStdErrContents,
+ bool stdOutErrRequired);
bool NoCache;
std::string RunResultVariable;
@@ -185,12 +186,17 @@ bool TryRunCommandImpl::TryRunCode(std::vector<std::string> const& argv)
std::string runOutputStdErrContents;
if (this->Makefile->IsOn("CMAKE_CROSSCOMPILING") &&
!this->Makefile->IsDefinitionSet("CMAKE_CROSSCOMPILING_EMULATOR")) {
+ // We only require the stdout/stderr cache entries if the project
+ // actually asked for the values, not just for logging.
+ bool const stdOutErrRequired = (arguments.RunOutputStdOutVariable ||
+ arguments.RunOutputStdErrVariable);
this->DoNotRunExecutable(
runArgs, *arguments.SourceDirectoryOrFile,
*arguments.CompileResultVariable,
captureRunOutput ? &runOutputContents : nullptr,
captureRunOutputStdOutErr ? &runOutputStdOutContents : nullptr,
- captureRunOutputStdOutErr ? &runOutputStdErrContents : nullptr);
+ captureRunOutputStdOutErr ? &runOutputStdErrContents : nullptr,
+ stdOutErrRequired);
} else {
this->RunExecutable(
runArgs, arguments.RunWorkingDirectory,
@@ -311,7 +317,7 @@ void TryRunCommandImpl::RunExecutable(const std::string& runArgs,
void TryRunCommandImpl::DoNotRunExecutable(
const std::string& runArgs, const std::string& srcFile,
std::string const& compileResultVariable, std::string* out,
- std::string* stdOut, std::string* stdErr)
+ std::string* stdOut, std::string* stdErr, bool stdOutErrRequired)
{
// copy the executable out of the CMakeFiles/ directory, so it is not
// removed at the end of try_run() and the user can run it manually
@@ -357,7 +363,7 @@ void TryRunCommandImpl::DoNotRunExecutable(
}
// is the output from the executable used ?
- if (stdOut || stdErr) {
+ if (stdOutErrRequired) {
if (!this->Makefile->GetDefinition(internalRunOutputStdOutName)) {
// if the variables doesn't exist, create it with a helpful error text
// and mark it as advanced