Skip to content
Snippets Groups Projects
Commit 043ed0ce authored by Brad King's avatar Brad King Committed by Kitware Robot
Browse files

Merge topic 'try_run-cross-compile'


5cd5c8ca Merge branch 'backport-try_run-cross-compile' into try_run-cross-compile
0191e8b5 try_run: Do not require unrequested stdout/stderr when cross-compiling
2f85ec0a try_run: Avoid crash in keyword-dispatched signature when cross-compiling

Acked-by: default avatarKitware Robot <kwrobot@kitware.com>
Acked-by: default avatarbuildbot <buildbot@kitware.com>
Merge-request: !8066
parents 73c86789 5cd5c8ca
No related merge requests found
......@@ -86,11 +86,12 @@ public:
std::string* runOutputStdOutContents,
std::string* runOutputStdErrContents);
void DoNotRunExecutable(const std::string& runArgs,
const std::string& srcFile,
cm::optional<std::string> const& srcFile,
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,
runArgs, arguments.SourceDirectoryOrFile,
*arguments.CompileResultVariable,
captureRunOutput ? &runOutputContents : nullptr,
captureRunOutputStdOutErr ? &runOutputStdOutContents : nullptr,
captureRunOutputStdOutErr ? &runOutputStdErrContents : nullptr);
captureRunOutputStdOutErr ? &runOutputStdErrContents : nullptr,
stdOutErrRequired);
} else {
this->RunExecutable(
runArgs, arguments.RunWorkingDirectory,
......@@ -309,9 +315,9 @@ void TryRunCommandImpl::RunExecutable(const std::string& runArgs,
the executable would have produced.
*/
void TryRunCommandImpl::DoNotRunExecutable(
const std::string& runArgs, const std::string& srcFile,
const std::string& runArgs, cm::optional<std::string> const& 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
......@@ -492,9 +498,11 @@ void TryRunCommandImpl::DoNotRunExecutable(
comment += "The ";
comment += compileResultVariable;
comment += " variable holds the build result for this try_run().\n\n"
"Source file : ";
comment += srcFile + "\n";
comment += " variable holds the build result for this try_run().\n\n";
if (srcFile) {
comment += "Source file : ";
comment += *srcFile + "\n";
}
comment += "Executable : ";
comment += copyDest + "\n";
comment += "Run arguments : ";
......
include(${CMAKE_CURRENT_SOURCE_DIR}/${try_compile_DEFS})
# Pretend we are cross-compiling to take that try_run code path.
set(CMAKE_CROSSCOMPILING 1)
set(RUN_RESULT 0)
try_run(RUN_RESULT COMPILE_RESULT ${try_compile_bindir_or_SOURCES}
${CMAKE_CURRENT_SOURCE_DIR}/src.c)
unset(CMAKE_CROSSCOMPILING)
......@@ -11,6 +11,8 @@ run_cmake(BadLinkLibraries)
run_cmake(BinDirEmpty)
run_cmake(BinDirRelative)
run_cmake(CrossCompile)
run_cmake(WorkingDirArg)
run_cmake(NoCompileOutputVariable)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment