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
|
||||
--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"
|
||||
|
4
Tests/TargetName/CMakeLists.txt
Normal file
4
Tests/TargetName/CMakeLists.txt
Normal file
@ -0,0 +1,4 @@
|
||||
project(TargetName)
|
||||
|
||||
add_subdirectory(executables)
|
||||
add_subdirectory(scripts)
|
1
Tests/TargetName/executables/CMakeLists.txt
Normal file
1
Tests/TargetName/executables/CMakeLists.txt
Normal file
@ -0,0 +1 @@
|
||||
add_executable(hello_world hello_world.c)
|
5
Tests/TargetName/executables/hello_world.c
Normal file
5
Tests/TargetName/executables/hello_world.c
Normal file
@ -0,0 +1,5 @@
|
||||
#include <stdio.h>
|
||||
main()
|
||||
{
|
||||
printf("hello, world\n");
|
||||
}
|
1
Tests/TargetName/scripts/.gitattributes
vendored
Normal file
1
Tests/TargetName/scripts/.gitattributes
vendored
Normal file
@ -0,0 +1 @@
|
||||
hello_world crlf=input
|
13
Tests/TargetName/scripts/CMakeLists.txt
Normal file
13
Tests/TargetName/scripts/CMakeLists.txt
Normal 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}")
|
2
Tests/TargetName/scripts/hello_world
Executable file
2
Tests/TargetName/scripts/hello_world
Executable file
@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
echo "hello, world"
|
Loading…
x
Reference in New Issue
Block a user