summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2016-11-01 13:14:37 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2016-11-01 13:14:37 (GMT)
commit505f56dc91a94446b907620881f9156c9a9dfc92 (patch)
treedc955519dadcb60230cad626180f588e238f958a /Tests
parent357305953600b0de49f0373888c8fe5eb1e7eef4 (diff)
parentf648b9be6347046583ee795f42e39713f248a608 (diff)
downloadCMake-505f56dc91a94446b907620881f9156c9a9dfc92.zip
CMake-505f56dc91a94446b907620881f9156c9a9dfc92.tar.gz
CMake-505f56dc91a94446b907620881f9156c9a9dfc92.tar.bz2
Merge topic 'custom-command-CROSSCOMPILING_EMULATOR'
f648b9be Tests: Check that CROSSCOMPILING_EMULATOR is not used on imported targets e7480d67 Fix custom command target substitution with CROSSCOMPILING_EMULATOR
Diffstat (limited to 'Tests')
-rw-r--r--Tests/RunCMake/CrosscompilingEmulator/AddCustomCommand.cmake17
-rw-r--r--Tests/RunCMake/CrosscompilingEmulator/AddCustomTarget.cmake16
-rw-r--r--Tests/RunCMake/CrosscompilingEmulator/generated_exe_emulator_unexpected.cxx9
-rw-r--r--Tests/RunCMake/CrosscompilingEmulator/simple_src_exitsuccess.cxx4
-rw-r--r--Tests/RunCMake/pseudo_emulator_custom_command.c3
5 files changed, 42 insertions, 7 deletions
diff --git a/Tests/RunCMake/CrosscompilingEmulator/AddCustomCommand.cmake b/Tests/RunCMake/CrosscompilingEmulator/AddCustomCommand.cmake
index 67fa30f..c4db11b 100644
--- a/Tests/RunCMake/CrosscompilingEmulator/AddCustomCommand.cmake
+++ b/Tests/RunCMake/CrosscompilingEmulator/AddCustomCommand.cmake
@@ -4,7 +4,15 @@ set(CMAKE_CROSSCOMPILING 1)
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)
+add_executable(generated_exe_emulator_unexpected generated_exe_emulator_unexpected.cxx)
+# Place the executable in a predictable location.
+set_property(TARGET generated_exe_emulator_unexpected PROPERTY RUNTIME_OUTPUT_DIRECTORY $<1:${CMAKE_CURRENT_BINARY_DIR}>)
+
+# Executable: Imported version of above. Fake the imported target to use the above.
+add_executable(generated_exe_emulator_unexpected_imported IMPORTED)
+set_property(TARGET generated_exe_emulator_unexpected_imported PROPERTY IMPORTED_LOCATION
+ "${CMAKE_CURRENT_BINARY_DIR}/generated_exe_emulator_unexpected${CMAKE_EXECUTABLE_SUFFIX}")
+add_dependencies(generated_exe_emulator_unexpected_imported generated_exe_emulator_unexpected)
# DoesNotUseEmulator
add_custom_command(OUTPUT output1
@@ -22,6 +30,12 @@ add_custom_command(OUTPUT output3
COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/output3
DEPENDS generated_exe_emulator_unexpected)
+# DoesNotUseEmulator: The command will fail if emulator is prepended
+add_custom_command(OUTPUT outputImp
+ COMMAND generated_exe_emulator_unexpected_imported
+ COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/outputImp
+ )
+
# UsesEmulator: The command only succeeds if the emulator is prepended
# to the command.
add_custom_command(OUTPUT output4
@@ -34,5 +48,6 @@ add_custom_target(ensure_build ALL
${CMAKE_CURRENT_BINARY_DIR}/output1
${CMAKE_CURRENT_BINARY_DIR}/output2
${CMAKE_CURRENT_BINARY_DIR}/output3
+ ${CMAKE_CURRENT_BINARY_DIR}/outputImp
${CMAKE_CURRENT_BINARY_DIR}/output4
)
diff --git a/Tests/RunCMake/CrosscompilingEmulator/AddCustomTarget.cmake b/Tests/RunCMake/CrosscompilingEmulator/AddCustomTarget.cmake
index ced569f..5b01abc 100644
--- a/Tests/RunCMake/CrosscompilingEmulator/AddCustomTarget.cmake
+++ b/Tests/RunCMake/CrosscompilingEmulator/AddCustomTarget.cmake
@@ -4,7 +4,15 @@ set(CMAKE_CROSSCOMPILING 1)
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)
+add_executable(generated_exe_emulator_unexpected generated_exe_emulator_unexpected.cxx)
+# Place the executable in a predictable location.
+set_property(TARGET generated_exe_emulator_unexpected PROPERTY RUNTIME_OUTPUT_DIRECTORY $<1:${CMAKE_CURRENT_BINARY_DIR}>)
+
+# Executable: Imported version of above. Fake the imported target to use the above.
+add_executable(generated_exe_emulator_unexpected_imported IMPORTED)
+set_property(TARGET generated_exe_emulator_unexpected_imported PROPERTY IMPORTED_LOCATION
+ "${CMAKE_CURRENT_BINARY_DIR}/generated_exe_emulator_unexpected${CMAKE_EXECUTABLE_SUFFIX}")
+add_dependencies(generated_exe_emulator_unexpected_imported generated_exe_emulator_unexpected)
# DoesNotUseEmulator
add_custom_target(generate_output1 ALL
@@ -22,6 +30,12 @@ add_custom_target(generate_output3 ALL
COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/output3
DEPENDS generated_exe_emulator_unexpected)
+# DoesNotUseEmulator: The command will fail if emulator is prepended
+add_custom_target(generate_outputImp ALL
+ COMMAND generated_exe_emulator_unexpected_imported
+ COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/outputImp
+ )
+
# UsesEmulator: The command only succeeds if the emulator is prepended
# to the command.
add_custom_target(generate_output4 ALL
diff --git a/Tests/RunCMake/CrosscompilingEmulator/generated_exe_emulator_unexpected.cxx b/Tests/RunCMake/CrosscompilingEmulator/generated_exe_emulator_unexpected.cxx
new file mode 100644
index 0000000..233f432
--- /dev/null
+++ b/Tests/RunCMake/CrosscompilingEmulator/generated_exe_emulator_unexpected.cxx
@@ -0,0 +1,9 @@
+#include <stdio.h>
+
+int main(int argc, const char* argv[])
+{
+ for (int i = 1; i < argc; ++i) {
+ fprintf(stderr, "unexpected argument: '%s'\n", argv[i]);
+ }
+ return argc == 1 ? 0 : 1;
+}
diff --git a/Tests/RunCMake/CrosscompilingEmulator/simple_src_exitsuccess.cxx b/Tests/RunCMake/CrosscompilingEmulator/simple_src_exitsuccess.cxx
deleted file mode 100644
index a3dd891..0000000
--- a/Tests/RunCMake/CrosscompilingEmulator/simple_src_exitsuccess.cxx
+++ /dev/null
@@ -1,4 +0,0 @@
-int main(int, char**)
-{
- return 0;
-}
diff --git a/Tests/RunCMake/pseudo_emulator_custom_command.c b/Tests/RunCMake/pseudo_emulator_custom_command.c
index 760e83c..3a94795 100644
--- a/Tests/RunCMake/pseudo_emulator_custom_command.c
+++ b/Tests/RunCMake/pseudo_emulator_custom_command.c
@@ -14,7 +14,8 @@
int main(int argc, const char* argv[])
{
const char* substring_failure = "generated_exe_emulator_unexpected";
- const char* substring_success = "generated_exe_emulator_expected";
+ // Require a slash to make sure it is a path and not a target name.
+ const char* substring_success = "/generated_exe_emulator_expected";
const char* str = argv[1];
if (argc < 2) {
return EXIT_FAILURE;