mirror of
https://github.com/Kitware/CMake.git
synced 2026-07-08 23:57:29 +00:00
Depend: Add test for target-level dependencies via byproducts
Add test for target-level dependency of custom target to POST_BUILD event via byproduct. Remove explicit dependencies in test which are no longe required due to introduced dependencies on build events via byproducts. Issue: #19005
This commit is contained in:
@@ -28,6 +28,7 @@ add_custom_target(Producer3_4
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/byproduct3.c.in byproduct3.c
|
||||
BYPRODUCTS byproduct3.c
|
||||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/byproduct3.c.in
|
||||
)
|
||||
|
||||
# Generate a byproduct in a custom target POST_BUILD command.
|
||||
@@ -36,32 +37,36 @@ add_custom_command(
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/byproduct4.c.in byproduct4.c
|
||||
BYPRODUCTS byproduct4.c
|
||||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/byproduct4.c.in
|
||||
)
|
||||
|
||||
add_executable(ProducerExe ProducerExe.c)
|
||||
add_executable(ProducerExe5_6_7 ProducerExe.c)
|
||||
|
||||
# Generate a byproduct in an executable POST_BUILD command.
|
||||
add_custom_command(
|
||||
TARGET ProducerExe POST_BUILD
|
||||
TARGET ProducerExe5_6_7 POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/byproduct5.c.in byproduct5.c
|
||||
BYPRODUCTS byproduct5.c
|
||||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/byproduct5.c.in
|
||||
)
|
||||
|
||||
# Generate a byproduct in an executable PRE_LINK command.
|
||||
add_custom_command(
|
||||
TARGET ProducerExe PRE_LINK
|
||||
TARGET ProducerExe5_6_7 PRE_LINK
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/byproduct6.c.in byproduct6.c
|
||||
BYPRODUCTS byproduct6.c
|
||||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/byproduct6.c.in
|
||||
)
|
||||
|
||||
# Generate a byproduct in an executable PRE_BUILD command.
|
||||
add_custom_command(
|
||||
TARGET ProducerExe PRE_BUILD
|
||||
TARGET ProducerExe5_6_7 PRE_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/byproduct7.c.in byproduct7.c
|
||||
BYPRODUCTS byproduct7.c
|
||||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/byproduct7.c.in
|
||||
)
|
||||
|
||||
# Generate a byproduct in a custom command that consumes other byproducts.
|
||||
@@ -80,6 +85,25 @@ add_custom_command(OUTPUT timestamp8.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/byproduct8.c.in
|
||||
)
|
||||
|
||||
add_executable(ProducerExe9 ProducerExe.c)
|
||||
|
||||
# Generate a byproduct in a custom target which depends on a byproduct of a
|
||||
# POST_BUILD command (test if dependency of custom target Producer9 to
|
||||
# ProducerExe9 is added).
|
||||
add_custom_command(
|
||||
TARGET ProducerExe9 POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/byproduct9.c.in byproduct9a.c
|
||||
BYPRODUCTS byproduct9a.c
|
||||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/byproduct9.c.in
|
||||
)
|
||||
add_custom_target(Producer9
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
byproduct9a.c byproduct9.c
|
||||
BYPRODUCTS byproduct9.c
|
||||
DEPENDS byproduct9a.c
|
||||
)
|
||||
|
||||
# Generate the library file of an imported target as a byproduct
|
||||
# of an external project.
|
||||
get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
|
||||
@@ -136,10 +160,13 @@ add_executable(CustomCommandByproducts
|
||||
byproduct6.c
|
||||
byproduct7.c
|
||||
byproduct8.c timestamp8.txt
|
||||
byproduct9.c
|
||||
)
|
||||
|
||||
# Dependencies to byproducts of custom commands other than build events are not
|
||||
# yet traced (see issue #19005).
|
||||
add_dependencies(CustomCommandByproducts Producer2)
|
||||
add_dependencies(CustomCommandByproducts Producer3_4)
|
||||
add_dependencies(CustomCommandByproducts ProducerExe)
|
||||
|
||||
target_link_libraries(CustomCommandByproducts ExternalLibrary)
|
||||
|
||||
if(CMAKE_GENERATOR STREQUAL "Ninja")
|
||||
|
||||
@@ -6,10 +6,11 @@ extern int byproduct5(void);
|
||||
extern int byproduct6(void);
|
||||
extern int byproduct7(void);
|
||||
extern int byproduct8(void);
|
||||
extern int byproduct9(void);
|
||||
extern int ExternalLibrary(void);
|
||||
int main(void)
|
||||
{
|
||||
return (byproduct1() + byproduct2() + byproduct3() + byproduct4() +
|
||||
byproduct5() + byproduct6() + byproduct7() + byproduct8() +
|
||||
ExternalLibrary() + 0);
|
||||
byproduct9() + ExternalLibrary() + 0);
|
||||
}
|
||||
|
||||
1
Tests/CustomCommandByproducts/byproduct9.c.in
Normal file
1
Tests/CustomCommandByproducts/byproduct9.c.in
Normal file
@@ -0,0 +1 @@
|
||||
int byproduct9(void) { return 0; }
|
||||
Reference in New Issue
Block a user