From 37f232d84f18958b8ed5abb1037929ff12a10ed2 Mon Sep 17 00:00:00 2001 From: PonomarevDA Date: Tue, 26 Dec 2023 00:27:26 +0300 Subject: [PATCH] fix GIT_HASH --- CMakeLists.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 74d3b07..cd33f9b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -126,6 +126,15 @@ add_custom_command(TARGET ${EXECUTABLE} COMMAND arm-none-eabi-size ${EXECUTABLE} ) +execute_process( + COMMAND git rev-parse --short=16 HEAD + COMMAND_ERROR_IS_FATAL ANY + OUTPUT_VARIABLE GIT_HASH_SHORT + OUTPUT_STRIP_TRAILING_WHITESPACE +) +set(GIT_HASH "0x${GIT_HASH_SHORT}") +add_definitions(-DGIT_HASH=${GIT_HASH}) + add_custom_command(TARGET ${EXECUTABLE} POST_BUILD COMMAND arm-none-eabi-objcopy -O ihex ${EXECUTABLE} ${PROJECT_NAME}.hex