Skip to content

Commit 68b6e6f

Browse files
committed
Fix post build mechanism with unique CMake custom targets
The CMake custom target must be unique to avoid more than one Mbed target adding the same. Only the CMake custom command added for the Mbed target being built is run as the custom CMake target now includes the Mbed target name.
1 parent ea6955b commit 68b6e6f

File tree

10 files changed

+20
-16
lines changed

10 files changed

+20
-16
lines changed

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,11 @@ function(mbed_generate_bin_hex target)
195195
VERBATIM
196196
)
197197

198-
if(TARGET mbed-post-build-bin)
198+
if(TARGET mbed-post-build-bin-${MBED_TARGET})
199199
add_custom_target(mbed-post-build
200200
ALL
201201
DEPENDS
202-
mbed-post-build-bin
202+
mbed-post-build-bin-${MBED_TARGET}
203203
)
204204
endif()
205205
endfunction()

targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYSBSYSKIT_01/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,4 @@ target_compile_definitions(mbed-cysbsyskit-01
5959
"CY8C624AFNI_S2D43F"
6060
)
6161

62-
mbed_post_build_psoc6_merge_hex()
62+
mbed_post_build_psoc6_merge_hex("CYSBSYSKIT_01")

targets/TARGET_Cypress/scripts/mbed_set_post_build_cypress.cmake

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,18 @@ include(${MBED_PATH}/tools/cmake/mbed_set_post_build.cmake)
66
#
77
# Merge Cortex-M4 HEX and a Cortex-M0 HEX.
88
#
9-
function(mbed_post_build_psoc6_merge_hex)
9+
function(mbed_post_build_psoc6_merge_hex mbed_target_name)
1010
find_package(Python3)
1111

12+
# Copy ${ARGN} to a variable first as it cannot be used directly with
13+
# the list() command
1214
set (extra_macro_args ${ARGN})
1315

14-
list(LENGTH cortex_m0_hex num_extra_args)
16+
# Get the number of arguments past the last expected argument
17+
list(LENGTH extra_macro_args num_extra_args)
1518

1619
if(${num_extra_args} GREATER 0)
20+
# Get extra argument as `cortex_m0_hex`
1721
list(GET extra_macro_args 0 cortex_m0_hex)
1822
set(post_build_command
1923
COMMAND ${Python3_EXECUTABLE} ${MBED_PATH}/targets/TARGET_Cypress/scripts/PSOC6.py

targets/TARGET_NXP/TARGET_LPC11XX_11CXX/TARGET_LPC11XX/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,3 @@ target_sources(mbed-lpc11xx
1616
)
1717

1818
target_link_libraries(mbed-lpc11xx INTERFACE mbed-lpc11xx-11cxx)
19-
20-
mbed_post_build_lpc_patch_vtable()

targets/TARGET_NXP/TARGET_LPC176X/TARGET_ARCH_PRO/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ target_include_directories(mbed-arch-pro
1212

1313
target_link_libraries(mbed-arch-pro INTERFACE mbed-lpc176x)
1414

15-
mbed_post_build_lpc_patch_vtable()
15+
mbed_post_build_lpc_patch_vtable("ARCH_PRO")

targets/TARGET_NXP/TARGET_LPC176X/TARGET_MBED_LPC1768/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ add_library(mbed-lpc1768 INTERFACE)
1616

1717
target_link_libraries(mbed-lpc1768 INTERFACE mbed-mbed-lpc1768)
1818

19-
mbed_post_build_lpc_patch_vtable()
19+
mbed_post_build_lpc_patch_vtable("LPC1768")

targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_LPC54114/device/TARGET_LPC54114_M4/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ target_sources(mbed-lpc54114-m4
3333

3434
mbed_set_linker_script(mbed-lpc54114-m4 ${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_FILE})
3535

36-
mbed_post_build_lpc_patch_vtable()
36+
mbed_post_build_lpc_patch_vtable("LPC54114")

targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_MCU_LPC546XX/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,5 @@ target_link_libraries(mbed-lpc546xx
9494
mbed-lpc546xx-xpresso
9595
)
9696

97-
mbed_post_build_lpc_patch_vtable()
97+
mbed_post_build_lpc_patch_vtable("LPC546XX")
98+
mbed_post_build_lpc_patch_vtable("FF_LPC546XX")

targets/TARGET_NXP/scripts/mbed_set_post_build_nxp.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ include(${MBED_PATH}/tools/cmake/mbed_set_post_build.cmake)
66
#
77
# Patch an LPC target vector table in the binary file.
88
#
9-
function(mbed_post_build_lpc_patch_vtable)
9+
function(mbed_post_build_lpc_patch_vtable mbed_target_name)
1010
find_package(Python3)
1111

1212
set(post_build_command

tools/cmake/mbed_set_post_build.cmake

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,17 @@
55
# Sets the post build operation for Mbed targets.
66
#
77
macro(mbed_set_post_build_operation)
8-
add_custom_target(mbed-post-build-bin
9-
DEPENDS ${CMAKE_BINARY_DIR}/${APP_TARGET}.bin
8+
9+
add_custom_target(mbed-post-build-bin-${mbed_target_name}
10+
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${APP_TARGET}.bin
1011
)
1112

1213
# Ensures the application artefacts are created before manipulating them.
13-
add_dependencies(mbed-post-build-bin ${APP_TARGET})
14+
add_dependencies(mbed-post-build-bin-${mbed_target_name} ${APP_TARGET})
1415

1516
add_custom_command(
1617
OUTPUT
17-
${CMAKE_BINARY_DIR}/${APP_TARGET}.bin
18+
${CMAKE_CURRENT_BINARY_DIR}/${APP_TARGET}.bin
1819
POST_BUILD
1920
COMMAND
2021
${post_build_command}

0 commit comments

Comments
 (0)