summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/CrosscompilingEmulator
diff options
context:
space:
mode:
authorJean-Christophe Fillion-Robin <jchris.fillionr@kitware.com>2016-05-04 17:30:19 (GMT)
committerBrad King <brad.king@kitware.com>2016-05-09 12:56:27 (GMT)
commit8c2cedc6243b281a0814b284abbcd1c45c42b085 (patch)
treeb4bd057053fff493dc9ed8f9538e5e039faa6e89 /Tests/RunCMake/CrosscompilingEmulator
parenteccfc0d185526b746b722ed3d3d1302515698c9e (diff)
downloadCMake-8c2cedc6243b281a0814b284abbcd1c45c42b085.zip
CMake-8c2cedc6243b281a0814b284abbcd1c45c42b085.tar.gz
CMake-8c2cedc6243b281a0814b284abbcd1c45c42b085.tar.bz2
CustomCommandGenerator: Add support for CROSSCOMPILING_EMULATOR
Teach the `add_custom_command` and `add_custom_target' commands to substitute argv0 with the crosscompiling emulator if it is a target with the `CROSSCOMPILING_EMULATOR` property set.
Diffstat (limited to 'Tests/RunCMake/CrosscompilingEmulator')
-rw-r--r--Tests/RunCMake/CrosscompilingEmulator/AddCustomCommand-build-check.cmake5
-rw-r--r--Tests/RunCMake/CrosscompilingEmulator/AddCustomCommand.cmake38
-rw-r--r--Tests/RunCMake/CrosscompilingEmulator/AddCustomTarget-build-check.cmake1
-rw-r--r--Tests/RunCMake/CrosscompilingEmulator/AddCustomTarget.cmake30
-rw-r--r--Tests/RunCMake/CrosscompilingEmulator/RunCMakeTest.cmake15
-rw-r--r--Tests/RunCMake/CrosscompilingEmulator/simple_src_exitsuccess.cxx4
6 files changed, 93 insertions, 0 deletions
diff --git a/Tests/RunCMake/CrosscompilingEmulator/AddCustomCommand-build-check.cmake b/Tests/RunCMake/CrosscompilingEmulator/AddCustomCommand-build-check.cmake
new file mode 100644
index 0000000..e10b161
--- /dev/null
+++ b/Tests/RunCMake/CrosscompilingEmulator/AddCustomCommand-build-check.cmake
@@ -0,0 +1,5 @@
+foreach(output IN ITEMS output1 output2 output3 output4)
+ if(NOT EXISTS "${RunCMake_TEST_BINARY_DIR}/${output}")
+ message(FATAL_ERROR "Failed to create output: ${RunCMake_TEST_BINARY_DIR}/${output}")
+ endif()
+endforeach()
diff --git a/Tests/RunCMake/CrosscompilingEmulator/AddCustomCommand.cmake b/Tests/RunCMake/CrosscompilingEmulator/AddCustomCommand.cmake
new file mode 100644
index 0000000..67fa30f
--- /dev/null
+++ b/Tests/RunCMake/CrosscompilingEmulator/AddCustomCommand.cmake
@@ -0,0 +1,38 @@
+set(CMAKE_CROSSCOMPILING 1)
+
+# Executable: Return error code different from 0
+add_executable(generated_exe_emulator_expected simple_src_exiterror.cxx)
+
+# Executable: Return error code equal to 0
+add_executable(generated_exe_emulator_unexpected simple_src_exitsuccess.cxx)
+
+# DoesNotUseEmulator
+add_custom_command(OUTPUT output1
+ COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/output1)
+
+# DoesNotUseEmulator: The command will fail if emulator is prepended
+add_custom_command(OUTPUT output2
+ COMMAND ${CMAKE_COMMAND} -E echo "$<TARGET_FILE:generated_exe_emulator_unexpected>"
+ COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/output2
+ DEPENDS generated_exe_emulator_unexpected)
+
+# DoesNotUseEmulator: The command will fail if emulator is prepended
+add_custom_command(OUTPUT output3
+ COMMAND $<TARGET_FILE:generated_exe_emulator_unexpected>
+ COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/output3
+ DEPENDS generated_exe_emulator_unexpected)
+
+# UsesEmulator: The command only succeeds if the emulator is prepended
+# to the command.
+add_custom_command(OUTPUT output4
+ COMMAND generated_exe_emulator_expected
+ COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/output4
+ DEPENDS generated_exe_emulator_expected)
+
+add_custom_target(ensure_build ALL
+ SOURCES
+ ${CMAKE_CURRENT_BINARY_DIR}/output1
+ ${CMAKE_CURRENT_BINARY_DIR}/output2
+ ${CMAKE_CURRENT_BINARY_DIR}/output3
+ ${CMAKE_CURRENT_BINARY_DIR}/output4
+)
diff --git a/Tests/RunCMake/CrosscompilingEmulator/AddCustomTarget-build-check.cmake b/Tests/RunCMake/CrosscompilingEmulator/AddCustomTarget-build-check.cmake
new file mode 100644
index 0000000..c621922
--- /dev/null
+++ b/Tests/RunCMake/CrosscompilingEmulator/AddCustomTarget-build-check.cmake
@@ -0,0 +1 @@
+include(${CMAKE_CURRENT_LIST_DIR}/AddCustomCommand-build-check.cmake)
diff --git a/Tests/RunCMake/CrosscompilingEmulator/AddCustomTarget.cmake b/Tests/RunCMake/CrosscompilingEmulator/AddCustomTarget.cmake
new file mode 100644
index 0000000..ced569f
--- /dev/null
+++ b/Tests/RunCMake/CrosscompilingEmulator/AddCustomTarget.cmake
@@ -0,0 +1,30 @@
+set(CMAKE_CROSSCOMPILING 1)
+
+# Executable: Return error code different from 0
+add_executable(generated_exe_emulator_expected simple_src_exiterror.cxx)
+
+# Executable: Return error code equal to 0
+add_executable(generated_exe_emulator_unexpected simple_src_exitsuccess.cxx)
+
+# DoesNotUseEmulator
+add_custom_target(generate_output1 ALL
+ ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/output1)
+
+# DoesNotUseEmulator: The command will fail if emulator is prepended
+add_custom_target(generate_output2 ALL
+ ${CMAKE_COMMAND} -E echo "$<TARGET_FILE:generated_exe_emulator_unexpected>"
+ COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/output2
+ DEPENDS generated_exe_emulator_unexpected)
+
+# DoesNotUseEmulator: The command will fail if emulator is prepended
+add_custom_target(generate_output3 ALL
+ $<TARGET_FILE:generated_exe_emulator_unexpected>
+ COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/output3
+ DEPENDS generated_exe_emulator_unexpected)
+
+# UsesEmulator: The command only succeeds if the emulator is prepended
+# to the command.
+add_custom_target(generate_output4 ALL
+ generated_exe_emulator_expected
+ COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/output4
+ DEPENDS generated_exe_emulator_expected)
diff --git a/Tests/RunCMake/CrosscompilingEmulator/RunCMakeTest.cmake b/Tests/RunCMake/CrosscompilingEmulator/RunCMakeTest.cmake
index 2581cfc..71aaad1 100644
--- a/Tests/RunCMake/CrosscompilingEmulator/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CrosscompilingEmulator/RunCMakeTest.cmake
@@ -6,3 +6,18 @@ set(RunCMake_TEST_OPTIONS
run_cmake(CrosscompilingEmulatorProperty)
run_cmake(TryRun)
run_cmake(AddTest)
+
+function(CustomCommandGenerator_run_and_build case)
+ # Use a single build tree for a few tests without cleaning.
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${case}-build)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ set(RunCMake_TEST_OPTIONS
+ "-DCMAKE_CROSSCOMPILING_EMULATOR=${PSEUDO_EMULATOR_CUSTOM_COMMAND}")
+ file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+ file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
+ run_cmake(${case})
+ run_cmake_command(${case}-build ${CMAKE_COMMAND} --build .)
+endfunction()
+
+CustomCommandGenerator_run_and_build(AddCustomCommand)
+CustomCommandGenerator_run_and_build(AddCustomTarget)
diff --git a/Tests/RunCMake/CrosscompilingEmulator/simple_src_exitsuccess.cxx b/Tests/RunCMake/CrosscompilingEmulator/simple_src_exitsuccess.cxx
new file mode 100644
index 0000000..630adc6
--- /dev/null
+++ b/Tests/RunCMake/CrosscompilingEmulator/simple_src_exitsuccess.cxx
@@ -0,0 +1,4 @@
+int main(int, char **)
+{
+ return 0;
+}