Skip to content

Commit 7da6100

Browse files
authored
Merge pull request #14304 from hugueskamba/hk_cmake_remove_app_target_reference
CMake: Refactor post-build hook to remove APP_TARGET references
2 parents 737153b + 0eae4f6 commit 7da6100

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

CMakeLists.txt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,13 @@ function(mbed_generate_bin_hex target)
186186
)
187187

188188
if(TARGET mbed-post-build-bin-${MBED_TARGET})
189-
add_custom_target(mbed-post-build
190-
ALL
191-
DEPENDS
192-
mbed-post-build-bin-${MBED_TARGET}
193-
)
189+
# The artefacts must be created before they can be further manipulated
190+
add_dependencies(mbed-post-build-bin-${MBED_TARGET} ${target})
191+
192+
# Add a post-build hook to the top-level CMake target in the form of a
193+
# CMake custom target. The hook depends on Mbed target specific
194+
# post-build CMake target which has a custom command attached to it.
195+
add_custom_target(mbed-post-build ALL DEPENDS mbed-post-build-bin-${MBED_TARGET})
194196
endif()
195197
endfunction()
196198

tools/cmake/mbed_set_post_build.cmake

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,11 @@
66
#
77
macro(mbed_set_post_build_operation)
88

9-
add_custom_target(mbed-post-build-bin-${mbed_target_name}
10-
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${APP_TARGET}.bin
11-
)
12-
13-
# Ensures the application artefacts are created before manipulating them.
14-
add_dependencies(mbed-post-build-bin-${mbed_target_name} ${APP_TARGET})
9+
add_custom_target(mbed-post-build-bin-${mbed_target_name})
1510

1611
add_custom_command(
17-
OUTPUT
18-
${CMAKE_CURRENT_BINARY_DIR}/${APP_TARGET}.bin
12+
TARGET
13+
mbed-post-build-bin-${mbed_target_name}
1914
POST_BUILD
2015
COMMAND
2116
${post_build_command}

0 commit comments

Comments
 (0)