From 579c4bec6e2352448f78d9333f7382ff34a08e5a Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Tue, 24 Mar 2015 00:02:50 -0400 Subject: [PATCH] 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. --- Help/manual/cmake-properties.7.rst | 1 + Help/manual/cmake-variables.7.rst | 1 + Help/prop_tgt/CROSSCOMPILING_EMULATOR.rst | 4 +++ .../CMAKE_CROSSCOMPILING_EMULATOR.rst | 5 ++++ Source/cmTarget.cxx | 1 + Tests/RunCMake/CMakeLists.txt | 4 +++ .../CrosscompilingEmulator/CMakeLists.txt | 3 ++ .../CrosscompilingEmulatorProperty.cmake | 28 +++++++++++++++++++ .../CrosscompilingEmulator/RunCMakeTest.cmake | 6 ++++ .../CrosscompilingEmulator/simple_src.cxx | 4 +++ Tests/RunCMake/pseudo_emulator.c | 15 ++++++++++ 11 files changed, 72 insertions(+) create mode 100644 Help/prop_tgt/CROSSCOMPILING_EMULATOR.rst create mode 100644 Help/variable/CMAKE_CROSSCOMPILING_EMULATOR.rst create mode 100644 Tests/RunCMake/CrosscompilingEmulator/CMakeLists.txt create mode 100644 Tests/RunCMake/CrosscompilingEmulator/CrosscompilingEmulatorProperty.cmake create mode 100644 Tests/RunCMake/CrosscompilingEmulator/RunCMakeTest.cmake create mode 100644 Tests/RunCMake/CrosscompilingEmulator/simple_src.cxx create mode 100644 Tests/RunCMake/pseudo_emulator.c diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index affa75f2a..02d164b5c 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 c342dbee1..63f704da5 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 000000000..2b5fd4d3d --- /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 000000000..fa6f1b743 --- /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 b3d115543..85e5165b1 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 60a8a8222..977721de8 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=$) diff --git a/Tests/RunCMake/CrosscompilingEmulator/CMakeLists.txt b/Tests/RunCMake/CrosscompilingEmulator/CMakeLists.txt new file mode 100644 index 000000000..2d7598574 --- /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 000000000..22d537c38 --- /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 000000000..cecc57f86 --- /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 000000000..630adc6bc --- /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 000000000..9308f75aa --- /dev/null +++ b/Tests/RunCMake/pseudo_emulator.c @@ -0,0 +1,15 @@ +#include + +int main(int argc, char * argv[] ) +{ + int ii; + + printf("Command:"); + for(ii = 1; ii < argc; ++ii) + { + printf(" \"%s\"", argv[ii]); + } + printf("\n"); + + return 42; +}