From 31a576abe674ba12021f75b574a4787458990cbd Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Mon, 27 Nov 2006 15:14:42 -0500 Subject: ENH: add a test for a target name with the same name as the output of a custom command --- Source/CMakeLists.txt | 12 ++++++++++++ Tests/TargetName/CMakeLists.txt | 4 ++++ Tests/TargetName/executables/CMakeLists.txt | 1 + Tests/TargetName/executables/hello_world.c | 5 +++++ Tests/TargetName/scripts/.gitattributes | 1 + Tests/TargetName/scripts/CMakeLists.txt | 13 +++++++++++++ Tests/TargetName/scripts/hello_world | 2 ++ 7 files changed, 38 insertions(+) create mode 100644 Tests/TargetName/CMakeLists.txt create mode 100644 Tests/TargetName/executables/CMakeLists.txt create mode 100644 Tests/TargetName/executables/hello_world.c create mode 100644 Tests/TargetName/scripts/.gitattributes create mode 100644 Tests/TargetName/scripts/CMakeLists.txt create mode 100755 Tests/TargetName/scripts/hello_world diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index fc0702d..0a1a2cb 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -390,6 +390,18 @@ IF(BUILD_TESTING) --build-project TestTar --test-command TestTarExec) + ADD_TEST(TargetName ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/TargetName" + "${CMake_BINARY_DIR}/Tests/TargetName" + --build-two-config + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-project TestTar + --test-command ${CMAKE_COMMAND} -E compare_files + ${CMake_SOURCE_DIR}/Tests/TargetName/scripts/hello_world + ${CMake_BINARY_DIR}/Tests/TargetName/scripts/hello_world) + ADD_TEST(CustomCommand ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/CustomCommand" diff --git a/Tests/TargetName/CMakeLists.txt b/Tests/TargetName/CMakeLists.txt new file mode 100644 index 0000000..653286e --- /dev/null +++ b/Tests/TargetName/CMakeLists.txt @@ -0,0 +1,4 @@ +project(TargetName) + +add_subdirectory(executables) +add_subdirectory(scripts) diff --git a/Tests/TargetName/executables/CMakeLists.txt b/Tests/TargetName/executables/CMakeLists.txt new file mode 100644 index 0000000..2671e3e --- /dev/null +++ b/Tests/TargetName/executables/CMakeLists.txt @@ -0,0 +1 @@ +add_executable(hello_world hello_world.c) diff --git a/Tests/TargetName/executables/hello_world.c b/Tests/TargetName/executables/hello_world.c new file mode 100644 index 0000000..539d867 --- /dev/null +++ b/Tests/TargetName/executables/hello_world.c @@ -0,0 +1,5 @@ +#include +main() +{ + printf("hello, world\n"); +} diff --git a/Tests/TargetName/scripts/.gitattributes b/Tests/TargetName/scripts/.gitattributes new file mode 100644 index 0000000..51b8ce9 --- /dev/null +++ b/Tests/TargetName/scripts/.gitattributes @@ -0,0 +1 @@ +hello_world crlf=input diff --git a/Tests/TargetName/scripts/CMakeLists.txt b/Tests/TargetName/scripts/CMakeLists.txt new file mode 100644 index 0000000..40d4e2f --- /dev/null +++ b/Tests/TargetName/scripts/CMakeLists.txt @@ -0,0 +1,13 @@ +if(NOT CMAKE_BINARY_DIR STREQUAL "${CMAKE_SOURCE_DIR}") + add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/hello_world + COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_CURRENT_SOURCE_DIR}/hello_world ${CMAKE_CURRENT_BINARY_DIR} + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/hello_world + ) + add_custom_target( + hello_world_copy ALL + DEPENDS #hello_world + ${CMAKE_CURRENT_BINARY_DIR}/hello_world + ) +endif(NOT CMAKE_BINARY_DIR STREQUAL "${CMAKE_SOURCE_DIR}") diff --git a/Tests/TargetName/scripts/hello_world b/Tests/TargetName/scripts/hello_world new file mode 100755 index 0000000..ea3a72c --- /dev/null +++ b/Tests/TargetName/scripts/hello_world @@ -0,0 +1,2 @@ +#!/bin/sh +echo "hello, world" -- cgit v0.12