Skip to content

Commit 0eae4f6

Browse files
committed
CMake: Refactor post-build hook to remove APP_TARGET references
There should not be a reference to APP_TARGET in Mbed OS as end-users may decide to use a different name for the CMake variable to store their application name.
1 parent 2660621 commit 0eae4f6

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
@@ -187,11 +187,13 @@ function(mbed_generate_bin_hex target)
187187
)
188188

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

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)