ENH: add a test for a target name with the same name as the output of a custom command
This commit is contained in:
parent
0954696e3e
commit
31a576abe6
|
@ -390,6 +390,18 @@ IF(BUILD_TESTING)
|
||||||
--build-project TestTar
|
--build-project TestTar
|
||||||
--test-command TestTarExec)
|
--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}
|
ADD_TEST(CustomCommand ${CMAKE_CTEST_COMMAND}
|
||||||
--build-and-test
|
--build-and-test
|
||||||
"${CMake_SOURCE_DIR}/Tests/CustomCommand"
|
"${CMake_SOURCE_DIR}/Tests/CustomCommand"
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
project(TargetName)
|
||||||
|
|
||||||
|
add_subdirectory(executables)
|
||||||
|
add_subdirectory(scripts)
|
|
@ -0,0 +1 @@
|
||||||
|
add_executable(hello_world hello_world.c)
|
|
@ -0,0 +1,5 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
main()
|
||||||
|
{
|
||||||
|
printf("hello, world\n");
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
hello_world crlf=input
|
|
@ -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}")
|
|
@ -0,0 +1,2 @@
|
||||||
|
#!/bin/sh
|
||||||
|
echo "hello, world"
|
Loading…
Reference in New Issue