From 0e36e3f05a81fe7fdd1c008a5f46503e68f85f7b Mon Sep 17 00:00:00 2001 From: Oxore Date: Tue, 7 Mar 2023 17:58:52 +0300 Subject: Add hex generation and print size after build --- CMakeLists.txt | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index 11a1a0b..8d1f859 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -130,7 +130,6 @@ target_compile_definitions(${PROJECT_NAME} PRIVATE __FREERTOS__=1 ) -# select linker script set(linker_script_mcu "${CMAKE_SOURCE_DIR}/app/ld/stm32f072x8.ld") set(linker_script_flash "${CMAKE_SOURCE_DIR}/app/ld/_flash.ld") set(linker_script_sram "${CMAKE_SOURCE_DIR}/app/ld/_sram.ld") @@ -150,6 +149,7 @@ target_compile_options(${PROJECT_NAME} PRIVATE $<$:-Wsuggest-final-methods> -fstrict-volatile-bitfields -ffunction-sections + -fdata-sections -g3 -Wall -Wextra @@ -182,3 +182,21 @@ set_property(TARGET ${PROJECT_NAME} PROPERTY LINK_DEPENDS ${linker_script_flash} ${linker_script_sram} ) + +set_property(TARGET ${PROJECT_NAME} PROPERTY SUFFIX ".elf") + +add_custom_command( + TARGET ${PROJECT_NAME} + POST_BUILD + COMMAND ${CMAKE_OBJSIZE} + $ +) + +add_custom_command( + TARGET ${PROJECT_NAME} + POST_BUILD + COMMAND ${CMAKE_OBJCOPY} + $ + -O ihex + $.hex +) -- cgit v1.2.3