ENH: add a test for a target name with the same name as the output of a custom command

This commit is contained in:
Bill Hoffman 2006-11-27 15:14:42 -05:00
parent 0954696e3e
commit 31a576abe6
7 changed files with 38 additions and 0 deletions

View File

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

View File

@ -0,0 +1,4 @@
project(TargetName)
add_subdirectory(executables)
add_subdirectory(scripts)

View File

@ -0,0 +1 @@
add_executable(hello_world hello_world.c)

View File

@ -0,0 +1,5 @@
#include <stdio.h>
main()
{
printf("hello, world\n");
}

View File

@ -0,0 +1 @@
hello_world crlf=input

View File

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

View File

@ -0,0 +1,2 @@
#!/bin/sh
echo "hello, world"