summaryrefslogtreecommitdiffstats
path: root/Source/cmTryRunCommand.cxx
diff options
context:
space:
mode:
authorMatt McCormick <matt.mccormick@kitware.com>2015-03-28 18:18:38 (GMT)
committerBrad King <brad.king@kitware.com>2015-04-08 13:06:22 (GMT)
commite942526b3d9e886da4ce832d9d3adb99cc5ede2f (patch)
tree92eb25f78e80acf587c3066750f3eafce13202a9 /Source/cmTryRunCommand.cxx
parent579c4bec6e2352448f78d9333f7382ff34a08e5a (diff)
downloadCMake-e942526b3d9e886da4ce832d9d3adb99cc5ede2f.zip
CMake-e942526b3d9e886da4ce832d9d3adb99cc5ede2f.tar.gz
CMake-e942526b3d9e886da4ce832d9d3adb99cc5ede2f.tar.bz2
try_run: Use CMAKE_CROSSCOMPILING_EMULATOR.
If the CMAKE_CROSSCOMPILING_EMULATOR variable is defined, and CMAKE_CROSSCOMPILING is TRUE, then use CMAKE_CROSSCOMPILING_EMULATOR to run the try_run executables. This prevents the need to populate TryRunResults.cmake when cross compiling.
Diffstat (limited to 'Source/cmTryRunCommand.cxx')
-rw-r--r--Source/cmTryRunCommand.cxx26
1 files changed, 24 insertions, 2 deletions
diff --git a/Source/cmTryRunCommand.cxx b/Source/cmTryRunCommand.cxx
index b5280cf..8b68d64 100644
--- a/Source/cmTryRunCommand.cxx
+++ b/Source/cmTryRunCommand.cxx
@@ -149,7 +149,8 @@ bool cmTryRunCommand
{
// "run" it and capture the output
std::string runOutputContents;
- if (this->Makefile->IsOn("CMAKE_CROSSCOMPILING"))
+ if (this->Makefile->IsOn("CMAKE_CROSSCOMPILING") &&
+ !this->Makefile->IsDefinitionSet("CMAKE_CROSSCOMPILING_EMULATOR"))
{
this->DoNotRunExecutable(runArgs,
argv[3],
@@ -195,7 +196,28 @@ void cmTryRunCommand::RunExecutable(const std::string& runArgs,
std::string* out)
{
int retVal = -1;
- std::string finalCommand = cmSystemTools::ConvertToRunCommandPath(
+
+ std::string finalCommand;
+ const std::string emulator =
+ this->Makefile->GetSafeDefinition("CMAKE_CROSSCOMPILING_EMULATOR");
+ if (!emulator.empty())
+ {
+ std::vector<std::string> emulatorWithArgs;
+ cmSystemTools::ExpandListArgument(emulator, emulatorWithArgs);
+ finalCommand += cmSystemTools::ConvertToRunCommandPath(
+ emulatorWithArgs[0].c_str());
+ finalCommand += " ";
+ for (std::vector<std::string>::const_iterator ei =
+ emulatorWithArgs.begin()+1;
+ ei != emulatorWithArgs.end(); ++ei)
+ {
+ finalCommand += "\"";
+ finalCommand += *ei;
+ finalCommand += "\"";
+ finalCommand += " ";
+ }
+ }
+ finalCommand += cmSystemTools::ConvertToRunCommandPath(
this->OutputFile.c_str());
if (!runArgs.empty())
{