summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt McCormick <matt.mccormick@kitware.com>2015-03-24 04:02:50 (GMT)
committerMatt McCormick <matt.mccormick@kitware.com>2015-04-07 17:33:34 (GMT)
commit579c4bec6e2352448f78d9333f7382ff34a08e5a (patch)
treedeb2161d3058d0ecdda1b126994cb5866d060853
parent7ee897beec045761e796ac7468ed6e43cd58f1fe (diff)
downloadCMake-579c4bec6e2352448f78d9333f7382ff34a08e5a.zip
CMake-579c4bec6e2352448f78d9333f7382ff34a08e5a.tar.gz
CMake-579c4bec6e2352448f78d9333f7382ff34a08e5a.tar.bz2
Properties: Add CROSSCOMPILING_EMULATOR target property.
Add CROSSCOMPILING_EMULATOR target property for executables. This is used by subsequent patches to run exectuables created for the target system when crosscompiling. The property is initialized by the CMAKE_CROSSCOMPILING_EMULATOR variable when defined.
-rw-r--r--Help/manual/cmake-properties.7.rst1
-rw-r--r--Help/manual/cmake-variables.7.rst1
-rw-r--r--Help/prop_tgt/CROSSCOMPILING_EMULATOR.rst4
-rw-r--r--Help/variable/CMAKE_CROSSCOMPILING_EMULATOR.rst5
-rw-r--r--Source/cmTarget.cxx1
-rw-r--r--Tests/RunCMake/CMakeLists.txt4
-rw-r--r--Tests/RunCMake/CrosscompilingEmulator/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/CrosscompilingEmulator/CrosscompilingEmulatorProperty.cmake28
-rw-r--r--Tests/RunCMake/CrosscompilingEmulator/RunCMakeTest.cmake6
-rw-r--r--Tests/RunCMake/CrosscompilingEmulator/simple_src.cxx4
-rw-r--r--Tests/RunCMake/pseudo_emulator.c15
11 files changed, 72 insertions, 0 deletions
diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst
index affa75f..02d164b 100644
--- a/Help/manual/cmake-properties.7.rst
+++ b/Help/manual/cmake-properties.7.rst
@@ -119,6 +119,7 @@ Properties on Targets
/prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG
/prop_tgt/CONFIG_OUTPUT_NAME
/prop_tgt/CONFIG_POSTFIX
+ /prop_tgt/CROSSCOMPILING_EMULATOR
/prop_tgt/CXX_EXTENSIONS
/prop_tgt/CXX_STANDARD
/prop_tgt/CXX_STANDARD_REQUIRED
diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst
index c342dbe..63f704d 100644
--- a/Help/manual/cmake-variables.7.rst
+++ b/Help/manual/cmake-variables.7.rst
@@ -25,6 +25,7 @@ Variables that Provide Information
/variable/CMAKE_CFG_INTDIR
/variable/CMAKE_COMMAND
/variable/CMAKE_CROSSCOMPILING
+ /variable/CMAKE_CROSSCOMPILING_EMULATOR
/variable/CMAKE_CTEST_COMMAND
/variable/CMAKE_CURRENT_BINARY_DIR
/variable/CMAKE_CURRENT_LIST_DIR
diff --git a/Help/prop_tgt/CROSSCOMPILING_EMULATOR.rst b/Help/prop_tgt/CROSSCOMPILING_EMULATOR.rst
new file mode 100644
index 0000000..2b5fd4d
--- /dev/null
+++ b/Help/prop_tgt/CROSSCOMPILING_EMULATOR.rst
@@ -0,0 +1,4 @@
+CROSSCOMPILING_EMULATOR
+-----------------------
+
+Use the given emulator to run executables created when crosscompiling.
diff --git a/Help/variable/CMAKE_CROSSCOMPILING_EMULATOR.rst b/Help/variable/CMAKE_CROSSCOMPILING_EMULATOR.rst
new file mode 100644
index 0000000..fa6f1b7
--- /dev/null
+++ b/Help/variable/CMAKE_CROSSCOMPILING_EMULATOR.rst
@@ -0,0 +1,5 @@
+CMAKE_CROSSCOMPILING_EMULATOR
+-----------------------------
+
+Default value for the :prop_tgt:`CROSSCOMPILING_EMULATOR` target property of
+executables. See that target property for additional information.
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index b3d1155..85e5165 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -442,6 +442,7 @@ void cmTarget::SetMakefile(cmMakefile* mf)
if(this->TargetTypeValue == cmTarget::EXECUTABLE)
{
this->SetPropertyDefault("ANDROID_GUI", 0);
+ this->SetPropertyDefault("CROSSCOMPILING_EMULATOR", 0);
}
if(this->TargetTypeValue == cmTarget::SHARED_LIBRARY
|| this->TargetTypeValue == cmTarget::MODULE_LIBRARY)
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index 60a8a82..977721d 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -226,3 +226,7 @@ add_RunCMake_test(COMPILE_LANGUAGE-genex)
if(CMake_TEST_FindMatlab)
add_RunCMake_test(FindMatlab)
endif()
+
+add_executable(pseudo_emulator pseudo_emulator.c)
+add_RunCMake_test(CrosscompilingEmulator
+ -DPSEUDO_EMULATOR=$<TARGET_FILE:pseudo_emulator>)
diff --git a/Tests/RunCMake/CrosscompilingEmulator/CMakeLists.txt b/Tests/RunCMake/CrosscompilingEmulator/CMakeLists.txt
new file mode 100644
index 0000000..2d75985
--- /dev/null
+++ b/Tests/RunCMake/CrosscompilingEmulator/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.1)
+project(${RunCMake_TEST} CXX)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/CrosscompilingEmulator/CrosscompilingEmulatorProperty.cmake b/Tests/RunCMake/CrosscompilingEmulator/CrosscompilingEmulatorProperty.cmake
new file mode 100644
index 0000000..22d537c
--- /dev/null
+++ b/Tests/RunCMake/CrosscompilingEmulator/CrosscompilingEmulatorProperty.cmake
@@ -0,0 +1,28 @@
+# This tests setting the CROSSCOMPILING_EMULATOR target property from the
+# CMAKE_CROSSCOMPILING_EMULATOR variable.
+
+# -DCMAKE_CROSSCOMPILING_EMULATOR=/path/to/pseudo_emulator is passed to this
+# test
+add_executable(target_with_emulator simple_src.cxx)
+get_property(emulator TARGET target_with_emulator
+ PROPERTY CROSSCOMPILING_EMULATOR)
+if(NOT "${emulator}" MATCHES "pseudo_emulator")
+ message(SEND_ERROR "Default CROSSCOMPILING_EMULATOR property not set")
+endif()
+
+set_property(TARGET target_with_emulator
+ PROPERTY CROSSCOMPILING_EMULATOR "another_emulator")
+get_property(emulator TARGET target_with_emulator
+ PROPERTY CROSSCOMPILING_EMULATOR)
+if(NOT "${emulator}" MATCHES "another_emulator")
+ message(SEND_ERROR
+ "set_property/get_property CROSSCOMPILING_EMULATOR is not consistent")
+endif()
+
+unset(CMAKE_CROSSCOMPILING_EMULATOR CACHE)
+add_executable(target_without_emulator simple_src.cxx)
+get_property(emulator TARGET target_without_emulator
+ PROPERTY CROSSCOMPILING_EMULATOR)
+if(NOT "${emulator}" STREQUAL "")
+ message(SEND_ERROR "Default CROSSCOMPILING_EMULATOR property not set to null")
+endif()
diff --git a/Tests/RunCMake/CrosscompilingEmulator/RunCMakeTest.cmake b/Tests/RunCMake/CrosscompilingEmulator/RunCMakeTest.cmake
new file mode 100644
index 0000000..cecc57f
--- /dev/null
+++ b/Tests/RunCMake/CrosscompilingEmulator/RunCMakeTest.cmake
@@ -0,0 +1,6 @@
+include(RunCMake)
+
+set(RunCMake_TEST_OPTIONS
+ "-DCMAKE_CROSSCOMPILING_EMULATOR=${PSEUDO_EMULATOR}")
+
+run_cmake(CrosscompilingEmulatorProperty)
diff --git a/Tests/RunCMake/CrosscompilingEmulator/simple_src.cxx b/Tests/RunCMake/CrosscompilingEmulator/simple_src.cxx
new file mode 100644
index 0000000..630adc6
--- /dev/null
+++ b/Tests/RunCMake/CrosscompilingEmulator/simple_src.cxx
@@ -0,0 +1,4 @@
+int main(int, char **)
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/pseudo_emulator.c b/Tests/RunCMake/pseudo_emulator.c
new file mode 100644
index 0000000..9308f75
--- /dev/null
+++ b/Tests/RunCMake/pseudo_emulator.c
@@ -0,0 +1,15 @@
+#include <stdio.h>
+
+int main(int argc, char * argv[] )
+{
+ int ii;
+
+ printf("Command:");
+ for(ii = 1; ii < argc; ++ii)
+ {
+ printf(" \"%s\"", argv[ii]);
+ }
+ printf("\n");
+
+ return 42;
+}