diff --git a/CMakeLists.txt b/CMakeLists.txt index c43fc4077db..4a615372775 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1327,6 +1327,7 @@ if(HEX_FILES_TO_MERGE) ) add_custom_target(mergehex ALL DEPENDS ${MERGED_HEX_NAME}) + list(APPEND FLASH_DEPS mergehex) endif() if(CONFIG_OUTPUT_PRINT_MEMORY_USAGE) diff --git a/cmake/flash/CMakeLists.txt b/cmake/flash/CMakeLists.txt index 64d4c591192..839544ba124 100644 --- a/cmake/flash/CMakeLists.txt +++ b/cmake/flash/CMakeLists.txt @@ -91,6 +91,8 @@ foreach(target flash debug debugserver attach) set(comment "Debugging ${BOARD}") endif() + list(APPEND FLASH_DEPS ${logical_target_for_zephyr_elf}) + # We pass --skip-rebuild here because the DEPENDS value ensures the # build is already up to date before west is run. set(cmd @@ -101,7 +103,7 @@ foreach(target flash debug debugserver attach) ${RUNNER_VERBOSE} ${target} --skip-rebuild - DEPENDS ${logical_target_for_zephyr_elf} + DEPENDS ${FLASH_DEPS} WORKING_DIRECTORY ${APPLICATION_BINARY_DIR} )