CMake: fix the output bin-hex file

$<TARGET_FILE:${target}> is the output from CMake. As it can contain suffix for some toolchains, we can use ${target} instead (output from hex/bin generation).
pull/13566/head
Martin Kojtal 2020-10-27 15:45:14 +00:00 committed by Hugues Kamba
parent 7171f62489
commit 52bc5b569c
1 changed files with 8 additions and 8 deletions

View File

@ -151,18 +151,18 @@ function(mbed_generate_bin_hex target)
get_property(elf_to_bin GLOBAL PROPERTY ELF2BIN)
if(MBED_TOOLCHAIN STREQUAL "GCC_ARM")
set(CMAKE_POST_BUILD_COMMAND
COMMAND ${elf_to_bin} -O binary $<TARGET_FILE:${target}> $<TARGET_FILE:${target}>.bin
COMMAND ${CMAKE_COMMAND} -E echo "-- built: $<TARGET_FILE:${target}>.bin"
COMMAND ${elf_to_bin} -O ihex $<TARGET_FILE:${target}> $<TARGET_FILE:${target}>.hex
COMMAND ${CMAKE_COMMAND} -E echo "-- built: $<TARGET_FILE:${target}>.hex"
COMMAND ${elf_to_bin} -O binary $<TARGET_FILE:${target}> ${CMAKE_BINARY_DIR}/${target}.bin
COMMAND ${CMAKE_COMMAND} -E echo "-- built: ${CMAKE_BINARY_DIR}/${target}.bin"
COMMAND ${elf_to_bin} -O ihex $<TARGET_FILE:${target}> ${CMAKE_BINARY_DIR}/${target}.hex
COMMAND ${CMAKE_COMMAND} -E echo "-- built: ${CMAKE_BINARY_DIR}/${target}.hex"
)
elseif(MBED_TOOLCHAIN STREQUAL "ARM")
get_property(mbed_studio_arm_compiler GLOBAL PROPERTY MBED_STUDIO_ARM_COMPILER)
set(CMAKE_POST_BUILD_COMMAND
COMMAND ${elf_to_bin} ${mbed_studio_arm_compiler} --bin -o $<TARGET_FILE:${target}>.bin $<TARGET_FILE:${target}>
COMMAND ${CMAKE_COMMAND} -E echo "-- built: $<TARGET_FILE:${target}>.bin"
COMMAND ${elf_to_bin} ${mbed_studio_arm_compiler} --i32combined -o $<TARGET_FILE:${target}>.hex $<TARGET_FILE:${target}>
COMMAND ${CMAKE_COMMAND} -E echo "-- built: $<TARGET_FILE:${target}>.hex"
COMMAND ${elf_to_bin} ${mbed_studio_arm_compiler} --bin -o ${CMAKE_BINARY_DIR}/${target}.bin $<TARGET_FILE:${target}>
COMMAND ${CMAKE_COMMAND} -E echo "-- built: ${target}.bin"
COMMAND ${elf_to_bin} ${mbed_studio_arm_compiler} --i32combined -o ${CMAKE_BINARY_DIR}/${target}.hex $<TARGET_FILE:${target}>
COMMAND ${CMAKE_COMMAND} -E echo "-- built: ${CMAKE_BINARY_DIR}/${target}.hex"
)
endif()
add_custom_command(