summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2015-04-08 13:07:03 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2015-04-08 13:07:03 (GMT)
commit977796e3077b390b72c32315138ca15ae3339fb7 (patch)
tree78d5a827316d2d9ca59bffe7aab4713359cfcb42 /Tests/RunCMake
parent37ce091345f6e9ad57aff7a768cc3dc35ebc3913 (diff)
parent1975d53ae19c46ee4f7384cc96be355f7e94df61 (diff)
downloadCMake-977796e3077b390b72c32315138ca15ae3339fb7.zip
CMake-977796e3077b390b72c32315138ca15ae3339fb7.tar.gz
CMake-977796e3077b390b72c32315138ca15ae3339fb7.tar.bz2
Merge topic 'emulator-property'
1975d53a Help: Add notes for topic 'emulator-property' 9160d6c2 TestGenerator: Add CROSSCOMPILING_EMULATOR support. e942526b try_run: Use CMAKE_CROSSCOMPILING_EMULATOR. 579c4bec Properties: Add CROSSCOMPILING_EMULATOR target property.
Diffstat (limited to 'Tests/RunCMake')
-rw-r--r--Tests/RunCMake/CMakeLists.txt4
-rw-r--r--Tests/RunCMake/CrosscompilingEmulator/AddTest-check.cmake12
-rw-r--r--Tests/RunCMake/CrosscompilingEmulator/AddTest.cmake8
-rw-r--r--Tests/RunCMake/CrosscompilingEmulator/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/CrosscompilingEmulator/CrosscompilingEmulatorProperty.cmake28
-rw-r--r--Tests/RunCMake/CrosscompilingEmulator/InitialCache.txt.in1
-rw-r--r--Tests/RunCMake/CrosscompilingEmulator/RunCMakeTest.cmake8
-rw-r--r--Tests/RunCMake/CrosscompilingEmulator/TryRun-stdout.txt1
-rw-r--r--Tests/RunCMake/CrosscompilingEmulator/TryRun.cmake18
-rw-r--r--Tests/RunCMake/CrosscompilingEmulator/simple_src.cxx4
-rw-r--r--Tests/RunCMake/pseudo_emulator.c15
11 files changed, 102 insertions, 0 deletions
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/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/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/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
new file mode 100644
index 0000000..2581cfc
--- /dev/null
+++ b/Tests/RunCMake/CrosscompilingEmulator/RunCMakeTest.cmake
@@ -0,0 +1,8 @@
+include(RunCMake)
+
+set(RunCMake_TEST_OPTIONS
+ "-DCMAKE_CROSSCOMPILING_EMULATOR=${PSEUDO_EMULATOR}")
+
+run_cmake(CrosscompilingEmulatorProperty)
+run_cmake(TryRun)
+run_cmake(AddTest)
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
new file mode 100644
index 0000000..e5e94f2
--- /dev/null
+++ b/Tests/RunCMake/CrosscompilingEmulator/simple_src.cxx
@@ -0,0 +1,4 @@
+int main(int, char **)
+{
+ return 13;
+}
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;
+}