Tests: Add missing POST_BUILD to custom commands

Issue: #21089
This commit is contained in:
Craig Scott
2024-08-25 14:21:58 +10:00
parent f5f80305ef
commit 316840b430
4 changed files with 7 additions and 4 deletions

View File

@@ -16,11 +16,11 @@ function(create_targets prefix)
get_write_file_command(cmd ${prefix}PostBuild.txt)
add_executable(${prefix}PostBuild ${CMAKE_SOURCE_DIR}/main.c)
add_custom_command(TARGET ${prefix}PostBuild COMMAND ${cmd} BYPRODUCTS ${prefix}PostBuild.txt)
add_custom_command(TARGET ${prefix}PostBuild POST_BUILD COMMAND ${cmd} BYPRODUCTS ${prefix}PostBuild.txt)
get_write_file_command(cmd ${prefix}TargetPostBuild.txt)
add_custom_target(${prefix}TargetPostBuild)
add_custom_command(TARGET ${prefix}TargetPostBuild COMMAND ${cmd} BYPRODUCTS ${prefix}TargetPostBuild.txt)
add_custom_command(TARGET ${prefix}TargetPostBuild POST_BUILD COMMAND ${cmd} BYPRODUCTS ${prefix}TargetPostBuild.txt)
file(APPEND "${CMAKE_BINARY_DIR}/target_files_custom.cmake"
"set(TARGET_DEPENDS_${prefix}Command [==[${CMAKE_CURRENT_BINARY_DIR}/${prefix}Command.txt]==])

View File

@@ -9,14 +9,17 @@ add_executable(exe "${main_file}")
# add one command for all and one for debug only
add_custom_command(TARGET exe
POST_BUILD
COMMAND "cmd_1" "cmd_1_arg"
COMMAND $<$<CONFIG:Debug>:cmd_1_dbg> $<$<CONFIG:Debug>:cmd_1_dbg_arg>)
# add command for debug only
add_custom_command(TARGET exe
POST_BUILD
COMMAND $<$<CONFIG:Debug>:cmd_2_dbg> $<$<CONFIG:Debug>:cmd_2_dbg_arg>)
# add separate commands for configurations
add_custom_command(TARGET exe
POST_BUILD
COMMAND $<$<CONFIG:Debug>:cmd_3_dbg> $<$<CONFIG:Debug>:cmd_3_dbg_arg>
COMMAND $<$<CONFIG:Release>:cmd_3_rel> $<$<CONFIG:Release>:cmd_3_rel_arg>)

View File

@@ -1,2 +1,2 @@
add_library(TargetImported UNKNOWN IMPORTED)
add_custom_command(TARGET TargetImported COMMAND ${CMAKE_COMMAND} -E echo tada)
add_custom_command(TARGET TargetImported POST_BUILD COMMAND ${CMAKE_COMMAND} -E echo tada)

View File

@@ -1,2 +1,2 @@
add_subdirectory(TargetNotInDir)
add_custom_command(TARGET TargetNotInDir COMMAND ${CMAKE_COMMAND} -E echo tada)
add_custom_command(TARGET TargetNotInDir POST_BUILD COMMAND ${CMAKE_COMMAND} -E echo tada)