diff --git a/tools/cmake/UploadMethodManager.cmake b/tools/cmake/UploadMethodManager.cmake index 4aa336d6f0b1..4e92db5d3b7f 100644 --- a/tools/cmake/UploadMethodManager.cmake +++ b/tools/cmake/UploadMethodManager.cmake @@ -59,8 +59,9 @@ set(MBED_UPLOAD_RESTART_COMMANDS ${UPLOAD_RESTART_COMMANDS} CACHE INTERNAL "" FO function(mbed_generate_upload_target target) # add upload target - gen_upload_target(${target} - ${CMAKE_CURRENT_BINARY_DIR}/$.bin - ${CMAKE_CURRENT_BINARY_DIR}/$.hex - ) + if ("${MBED_OUTPUT_EXT}" STREQUAL "" OR MBED_OUTPUT_EXT STREQUAL "bin") + gen_upload_target(${target} ${CMAKE_CURRENT_BINARY_DIR}/$.bin) + else() + gen_upload_target(${target} ${CMAKE_CURRENT_BINARY_DIR}/$.hex) + endif() endfunction() \ No newline at end of file