Skip to content

Commit 52bc5b5

Browse files
0xc0170hugueskamba
authored andcommitted
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).
1 parent 7171f62 commit 52bc5b5

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

CMakeLists.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -151,18 +151,18 @@ function(mbed_generate_bin_hex target)
151151
get_property(elf_to_bin GLOBAL PROPERTY ELF2BIN)
152152
if(MBED_TOOLCHAIN STREQUAL "GCC_ARM")
153153
set(CMAKE_POST_BUILD_COMMAND
154-
COMMAND ${elf_to_bin} -O binary $<TARGET_FILE:${target}> $<TARGET_FILE:${target}>.bin
155-
COMMAND ${CMAKE_COMMAND} -E echo "-- built: $<TARGET_FILE:${target}>.bin"
156-
COMMAND ${elf_to_bin} -O ihex $<TARGET_FILE:${target}> $<TARGET_FILE:${target}>.hex
157-
COMMAND ${CMAKE_COMMAND} -E echo "-- built: $<TARGET_FILE:${target}>.hex"
154+
COMMAND ${elf_to_bin} -O binary $<TARGET_FILE:${target}> ${CMAKE_BINARY_DIR}/${target}.bin
155+
COMMAND ${CMAKE_COMMAND} -E echo "-- built: ${CMAKE_BINARY_DIR}/${target}.bin"
156+
COMMAND ${elf_to_bin} -O ihex $<TARGET_FILE:${target}> ${CMAKE_BINARY_DIR}/${target}.hex
157+
COMMAND ${CMAKE_COMMAND} -E echo "-- built: ${CMAKE_BINARY_DIR}/${target}.hex"
158158
)
159159
elseif(MBED_TOOLCHAIN STREQUAL "ARM")
160160
get_property(mbed_studio_arm_compiler GLOBAL PROPERTY MBED_STUDIO_ARM_COMPILER)
161161
set(CMAKE_POST_BUILD_COMMAND
162-
COMMAND ${elf_to_bin} ${mbed_studio_arm_compiler} --bin -o $<TARGET_FILE:${target}>.bin $<TARGET_FILE:${target}>
163-
COMMAND ${CMAKE_COMMAND} -E echo "-- built: $<TARGET_FILE:${target}>.bin"
164-
COMMAND ${elf_to_bin} ${mbed_studio_arm_compiler} --i32combined -o $<TARGET_FILE:${target}>.hex $<TARGET_FILE:${target}>
165-
COMMAND ${CMAKE_COMMAND} -E echo "-- built: $<TARGET_FILE:${target}>.hex"
162+
COMMAND ${elf_to_bin} ${mbed_studio_arm_compiler} --bin -o ${CMAKE_BINARY_DIR}/${target}.bin $<TARGET_FILE:${target}>
163+
COMMAND ${CMAKE_COMMAND} -E echo "-- built: ${target}.bin"
164+
COMMAND ${elf_to_bin} ${mbed_studio_arm_compiler} --i32combined -o ${CMAKE_BINARY_DIR}/${target}.hex $<TARGET_FILE:${target}>
165+
COMMAND ${CMAKE_COMMAND} -E echo "-- built: ${CMAKE_BINARY_DIR}/${target}.hex"
166166
)
167167
endif()
168168
add_custom_command(

0 commit comments

Comments
 (0)