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.
This commit is contained in:
Matt McCormick 2015-03-24 00:02:50 -04:00
parent 7ee897beec
commit 579c4bec6e
11 changed files with 72 additions and 0 deletions

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,4 @@
CROSSCOMPILING_EMULATOR
-----------------------
Use the given emulator to run executables created when crosscompiling.

View File

@ -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.

View File

@ -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)

View File

@ -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>)

View File

@ -0,0 +1,3 @@
cmake_minimum_required(VERSION 3.1)
project(${RunCMake_TEST} CXX)
include(${RunCMake_TEST}.cmake)

View File

@ -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()

View File

@ -0,0 +1,6 @@
include(RunCMake)
set(RunCMake_TEST_OPTIONS
"-DCMAKE_CROSSCOMPILING_EMULATOR=${PSEUDO_EMULATOR}")
run_cmake(CrosscompilingEmulatorProperty)

View File

@ -0,0 +1,4 @@
int main(int, char **)
{
return 0;
}

View File

@ -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;
}