mirror of
https://github.com/Kitware/CMake.git
synced 2026-03-06 06:38:37 -06:00
Merge branch 'backport-try_run-cross-compile' into try_run-cross-compile
This commit is contained in:
@@ -86,7 +86,7 @@ public:
|
|||||||
std::string* runOutputStdOutContents,
|
std::string* runOutputStdOutContents,
|
||||||
std::string* runOutputStdErrContents);
|
std::string* runOutputStdErrContents);
|
||||||
void DoNotRunExecutable(const std::string& runArgs,
|
void DoNotRunExecutable(const std::string& runArgs,
|
||||||
const std::string& srcFile,
|
cm::optional<std::string> const& srcFile,
|
||||||
std::string const& compileResultVariable,
|
std::string const& compileResultVariable,
|
||||||
std::string* runOutputContents,
|
std::string* runOutputContents,
|
||||||
std::string* runOutputStdOutContents,
|
std::string* runOutputStdOutContents,
|
||||||
@@ -191,7 +191,7 @@ bool TryRunCommandImpl::TryRunCode(std::vector<std::string> const& argv)
|
|||||||
bool const stdOutErrRequired = (arguments.RunOutputStdOutVariable ||
|
bool const stdOutErrRequired = (arguments.RunOutputStdOutVariable ||
|
||||||
arguments.RunOutputStdErrVariable);
|
arguments.RunOutputStdErrVariable);
|
||||||
this->DoNotRunExecutable(
|
this->DoNotRunExecutable(
|
||||||
runArgs, *arguments.SourceDirectoryOrFile,
|
runArgs, arguments.SourceDirectoryOrFile,
|
||||||
*arguments.CompileResultVariable,
|
*arguments.CompileResultVariable,
|
||||||
captureRunOutput ? &runOutputContents : nullptr,
|
captureRunOutput ? &runOutputContents : nullptr,
|
||||||
captureRunOutputStdOutErr ? &runOutputStdOutContents : nullptr,
|
captureRunOutputStdOutErr ? &runOutputStdOutContents : nullptr,
|
||||||
@@ -315,7 +315,7 @@ void TryRunCommandImpl::RunExecutable(const std::string& runArgs,
|
|||||||
the executable would have produced.
|
the executable would have produced.
|
||||||
*/
|
*/
|
||||||
void TryRunCommandImpl::DoNotRunExecutable(
|
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 const& compileResultVariable, std::string* out,
|
||||||
std::string* stdOut, std::string* stdErr, bool stdOutErrRequired)
|
std::string* stdOut, std::string* stdErr, bool stdOutErrRequired)
|
||||||
{
|
{
|
||||||
@@ -498,9 +498,11 @@ void TryRunCommandImpl::DoNotRunExecutable(
|
|||||||
|
|
||||||
comment += "The ";
|
comment += "The ";
|
||||||
comment += compileResultVariable;
|
comment += compileResultVariable;
|
||||||
comment += " variable holds the build result for this try_run().\n\n"
|
comment += " variable holds the build result for this try_run().\n\n";
|
||||||
"Source file : ";
|
if (srcFile) {
|
||||||
comment += srcFile + "\n";
|
comment += "Source file : ";
|
||||||
|
comment += *srcFile + "\n";
|
||||||
|
}
|
||||||
comment += "Executable : ";
|
comment += "Executable : ";
|
||||||
comment += copyDest + "\n";
|
comment += copyDest + "\n";
|
||||||
comment += "Run arguments : ";
|
comment += "Run arguments : ";
|
||||||
|
|||||||
8
Tests/RunCMake/try_run/CrossCompile.cmake
Normal file
8
Tests/RunCMake/try_run/CrossCompile.cmake
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
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(BinDirEmpty)
|
||||||
run_cmake(BinDirRelative)
|
run_cmake(BinDirRelative)
|
||||||
|
|
||||||
|
run_cmake(CrossCompile)
|
||||||
|
|
||||||
run_cmake(WorkingDirArg)
|
run_cmake(WorkingDirArg)
|
||||||
|
|
||||||
run_cmake(NoCompileOutputVariable)
|
run_cmake(NoCompileOutputVariable)
|
||||||
|
|||||||
Reference in New Issue
Block a user