[Cmake-commits] CMake branch, next, updated. v3.2.1-1615-g0cc3714

Brad King brad.king at kitware.com
Wed Apr 8 09:06:42 EDT 2015


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, next has been updated
       via  0cc3714f771d042fe92ecd5479e555c0fe83b645 (commit)
       via  1975d53ae19c46ee4f7384cc96be355f7e94df61 (commit)
       via  9160d6c241adaeacc106d5b2ce4530f223345f22 (commit)
       via  e942526b3d9e886da4ce832d9d3adb99cc5ede2f (commit)
      from  7f0d8f29b814a77168f1df22030ddb161972759a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0cc3714f771d042fe92ecd5479e555c0fe83b645
commit 0cc3714f771d042fe92ecd5479e555c0fe83b645
Merge: 7f0d8f2 1975d53
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Wed Apr 8 09:06:41 2015 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Wed Apr 8 09:06:41 2015 -0400

    Merge topic 'emulator-property' into next
    
    1975d53a Help: Add notes for topic 'emulator-property'
    9160d6c2 TestGenerator: Add CROSSCOMPILING_EMULATOR support.
    e942526b try_run: Use CMAKE_CROSSCOMPILING_EMULATOR.


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1975d53ae19c46ee4f7384cc96be355f7e94df61
commit 1975d53ae19c46ee4f7384cc96be355f7e94df61
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Wed Apr 8 09:03:45 2015 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Wed Apr 8 09:06:22 2015 -0400

    Help: Add notes for topic 'emulator-property'

diff --git a/Help/release/dev/emulator-property.rst b/Help/release/dev/emulator-property.rst
new file mode 100644
index 0000000..1bc2f2d
--- /dev/null
+++ b/Help/release/dev/emulator-property.rst
@@ -0,0 +1,7 @@
+emulator-property
+-----------------
+
+* A :prop_tgt:`CROSSCOMPILING_EMULATOR` target property and supporting
+  :variable:`CMAKE_CROSSCOMPILING_EMULATOR` variable were introduced
+  to allow target platform binaries to run on the host during cross
+  compiling.

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9160d6c241adaeacc106d5b2ce4530f223345f22
commit 9160d6c241adaeacc106d5b2ce4530f223345f22
Author:     Matt McCormick <matt.mccormick at kitware.com>
AuthorDate: Sat Mar 28 22:05:35 2015 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Wed Apr 8 09:06:22 2015 -0400

    TestGenerator: Add CROSSCOMPILING_EMULATOR support.
    
    Prefix test commands with the CROSSCOMPILING_EMULATOR property
    for target executables. This allows test suites to be run on the host
    when crosscompiling.

diff --git a/Help/prop_tgt/CROSSCOMPILING_EMULATOR.rst b/Help/prop_tgt/CROSSCOMPILING_EMULATOR.rst
index 2b5fd4d..3ef8e03 100644
--- a/Help/prop_tgt/CROSSCOMPILING_EMULATOR.rst
+++ b/Help/prop_tgt/CROSSCOMPILING_EMULATOR.rst
@@ -1,4 +1,6 @@
 CROSSCOMPILING_EMULATOR
 -----------------------
 
-Use the given emulator to run executables created when crosscompiling.
+Use the given emulator to run executables created when crosscompiling.  This
+command will be added as a prefix to :command:`add_test` test commands for
+built target system executables.
diff --git a/Source/cmTestGenerator.cxx b/Source/cmTestGenerator.cxx
index f87a535..add80fa 100644
--- a/Source/cmTestGenerator.cxx
+++ b/Source/cmTestGenerator.cxx
@@ -82,11 +82,31 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os,
   // be translated.
   std::string exe = command[0];
   cmMakefile* mf = this->Test->GetMakefile();
+  cmLocalGenerator* lg = mf->GetLocalGenerator();
   cmTarget* target = mf->FindTargetToUse(exe);
   if(target && target->GetType() == cmTarget::EXECUTABLE)
     {
     // Use the target file on disk.
     exe = target->GetFullPath(config);
+
+    // Prepend with the emulator when cross compiling if required.
+    const char * emulator =
+      target->GetProperty("CROSSCOMPILING_EMULATOR");
+    if (emulator != 0)
+      {
+      std::vector<std::string> emulatorWithArgs;
+      cmSystemTools::ExpandListArgument(emulator, emulatorWithArgs);
+      std::string emulatorExe(emulatorWithArgs[0]);
+      cmSystemTools::ConvertToUnixSlashes(emulatorExe);
+      os << lg->EscapeForCMake(emulatorExe) << " ";
+      for(std::vector<std::string>::const_iterator ei =
+          emulatorWithArgs.begin()+1;
+          ei != emulatorWithArgs.end();
+          ++ei)
+        {
+        os << lg->EscapeForCMake(*ei) << " ";
+        }
+      }
     }
   else
     {
@@ -96,7 +116,6 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os,
     }
 
   // Generate the command line with full escapes.
-  cmLocalGenerator* lg = mf->GetLocalGenerator();
   os << lg->EscapeForCMake(exe);
   for(std::vector<std::string>::const_iterator ci = command.begin()+1;
       ci != command.end(); ++ci)
diff --git a/Tests/RunCMake/CrosscompilingEmulator/AddTest-check.cmake b/Tests/RunCMake/CrosscompilingEmulator/AddTest-check.cmake
new file mode 100644
index 0000000..0aae06c
--- /dev/null
+++ b/Tests/RunCMake/CrosscompilingEmulator/AddTest-check.cmake
@@ -0,0 +1,12 @@
+set(testfile "${RunCMake_TEST_BINARY_DIR}/CTestTestfile.cmake")
+if(EXISTS "${testfile}")
+  file(READ "${testfile}" testfile_contents)
+else()
+  message(FATAL_ERROR "Could not find expected CTestTestfile.cmake.")
+endif()
+if(testfile_contents MATCHES "add_test[(]DoesNotUseEmulator ^(pseudo_emulator)+$")
+  message(SEND_ERROR "Used emulator when it should not be used.")
+endif()
+if(NOT testfile_contents MATCHES "add_test[(]UsesEmulator .+pseudo_emulator.+$")
+  message(SEND_ERROR "Did not use emulator when it should be used.")
+endif()
diff --git a/Tests/RunCMake/CrosscompilingEmulator/AddTest.cmake b/Tests/RunCMake/CrosscompilingEmulator/AddTest.cmake
new file mode 100644
index 0000000..41850f2
--- /dev/null
+++ b/Tests/RunCMake/CrosscompilingEmulator/AddTest.cmake
@@ -0,0 +1,8 @@
+set(CMAKE_CROSSCOMPILING 1)
+enable_testing()
+add_test(NAME DoesNotUseEmulator
+  COMMAND ${CMAKE_COMMAND} -E echo "Hi")
+
+add_executable(generated_exe simple_src.cxx)
+add_test(NAME UsesEmulator
+  COMMAND generated_exe)
diff --git a/Tests/RunCMake/CrosscompilingEmulator/InitialCache.txt.in b/Tests/RunCMake/CrosscompilingEmulator/InitialCache.txt.in
new file mode 100644
index 0000000..c95fd8b
--- /dev/null
+++ b/Tests/RunCMake/CrosscompilingEmulator/InitialCache.txt.in
@@ -0,0 +1 @@
+CMAKE_EMULATOR:STRING=@PSEUDO_EMULATOR@
diff --git a/Tests/RunCMake/CrosscompilingEmulator/RunCMakeTest.cmake b/Tests/RunCMake/CrosscompilingEmulator/RunCMakeTest.cmake
index 04fb7db..2581cfc 100644
--- a/Tests/RunCMake/CrosscompilingEmulator/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CrosscompilingEmulator/RunCMakeTest.cmake
@@ -5,3 +5,4 @@ set(RunCMake_TEST_OPTIONS
 
 run_cmake(CrosscompilingEmulatorProperty)
 run_cmake(TryRun)
+run_cmake(AddTest)

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e942526b3d9e886da4ce832d9d3adb99cc5ede2f
commit e942526b3d9e886da4ce832d9d3adb99cc5ede2f
Author:     Matt McCormick <matt.mccormick at kitware.com>
AuthorDate: Sat Mar 28 14:18:38 2015 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Wed Apr 8 09:06:22 2015 -0400

    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.

diff --git a/Help/command/try_run.rst b/Help/command/try_run.rst
index 43ee219..e3bd57d 100644
--- a/Help/command/try_run.rst
+++ b/Help/command/try_run.rst
@@ -73,7 +73,8 @@ When cross compiling, the executable compiled in the first step
 usually cannot be run on the build host.  The ``try_run`` command checks
 the :variable:`CMAKE_CROSSCOMPILING` variable to detect whether CMake is in
 cross-compiling mode.  If that is the case, it will still try to compile
-the executable, but it will not try to run the executable.  Instead it
+the executable, but it will not try to run the executable unless the
+:variable:`CMAKE_CROSSCOMPILING_EMULATOR` variable is set.  Instead it
 will create cache variables which must be filled by the user or by
 presetting them in some CMake script file to the values the executable
 would have produced if it had been run on its actual target platform.
diff --git a/Help/variable/CMAKE_CROSSCOMPILING_EMULATOR.rst b/Help/variable/CMAKE_CROSSCOMPILING_EMULATOR.rst
index fa6f1b7..95d2c7f 100644
--- a/Help/variable/CMAKE_CROSSCOMPILING_EMULATOR.rst
+++ b/Help/variable/CMAKE_CROSSCOMPILING_EMULATOR.rst
@@ -1,5 +1,12 @@
 CMAKE_CROSSCOMPILING_EMULATOR
 -----------------------------
 
-Default value for the :prop_tgt:`CROSSCOMPILING_EMULATOR` target property of
-executables.  See that target property for additional information.
+This variable is only used when :variable:`CMAKE_CROSSCOMPILING` is on. It
+should point to a command on the host system that can run executable built
+for the target system.
+
+The command will be used to run :command:`try_run` generated executables,
+which avoids manual population of the TryRunResults.cmake file.
+
+It is also used as the default value for the
+:prop_tgt:`CROSSCOMPILING_EMULATOR` target property of executables.
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())
     {
diff --git a/Tests/RunCMake/CrosscompilingEmulator/RunCMakeTest.cmake b/Tests/RunCMake/CrosscompilingEmulator/RunCMakeTest.cmake
index cecc57f..04fb7db 100644
--- a/Tests/RunCMake/CrosscompilingEmulator/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CrosscompilingEmulator/RunCMakeTest.cmake
@@ -4,3 +4,4 @@ set(RunCMake_TEST_OPTIONS
     "-DCMAKE_CROSSCOMPILING_EMULATOR=${PSEUDO_EMULATOR}")
 
 run_cmake(CrosscompilingEmulatorProperty)
+run_cmake(TryRun)
diff --git a/Tests/RunCMake/CrosscompilingEmulator/TryRun-stdout.txt b/Tests/RunCMake/CrosscompilingEmulator/TryRun-stdout.txt
new file mode 100644
index 0000000..d012974
--- /dev/null
+++ b/Tests/RunCMake/CrosscompilingEmulator/TryRun-stdout.txt
@@ -0,0 +1 @@
+run_result: 42
diff --git a/Tests/RunCMake/CrosscompilingEmulator/TryRun.cmake b/Tests/RunCMake/CrosscompilingEmulator/TryRun.cmake
new file mode 100644
index 0000000..4851cc7
--- /dev/null
+++ b/Tests/RunCMake/CrosscompilingEmulator/TryRun.cmake
@@ -0,0 +1,18 @@
+set(CMAKE_CROSSCOMPILING 1)
+
+try_run(run_result compile_result
+  ${CMAKE_CURRENT_BINARY_DIR}
+  ${CMAKE_CURRENT_SOURCE_DIR}/simple_src.cxx
+  RUN_OUTPUT_VARIABLE run_output)
+
+message(STATUS "run_output: ${run_output}")
+message(STATUS "run_result: ${run_result}")
+
+set(CMAKE_CROSSCOMPILING_EMULATOR ${CMAKE_CROSSCOMPILING_EMULATOR}
+  --flag
+  "multi arg")
+try_run(run_result compile_result
+  ${CMAKE_CURRENT_BINARY_DIR}
+  ${CMAKE_CURRENT_SOURCE_DIR}/simple_src.cxx
+  RUN_OUTPUT_VARIABLE run_output)
+message(STATUS "Emulator with arguments run_output: ${run_output}")
diff --git a/Tests/RunCMake/CrosscompilingEmulator/simple_src.cxx b/Tests/RunCMake/CrosscompilingEmulator/simple_src.cxx
index 630adc6..e5e94f2 100644
--- a/Tests/RunCMake/CrosscompilingEmulator/simple_src.cxx
+++ b/Tests/RunCMake/CrosscompilingEmulator/simple_src.cxx
@@ -1,4 +1,4 @@
 int main(int, char **)
 {
-  return 0;
+  return 13;
 }

-----------------------------------------------------------------------

Summary of changes:


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list