Generate COMMIT_HASH define via CMake

Previously the commit hash was generated with a python script which was only
called by PlatformIO and caused issues when using Zephyr SDK directly.
This commit is contained in:
Martin Jäger
2020-07-23 17:34:41 +02:00
parent c2ef955a63
commit 5e213fdfb1
5 changed files with 13 additions and 27 deletions
+12
View File
@@ -12,3 +12,15 @@ add_subdirectory(../src build/src)
add_subdirectory(../lib/thingset build/thingset)
add_subdirectory(../lib/oled-display build/oled-display)
# determine git commit hash and provide it as a compiler define
find_package(Git)
if(GIT_FOUND)
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
OUTPUT_VARIABLE COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE)
else()
set(COMMIT_HASH "")
endif()
add_definitions(-DCOMMIT_HASH="${COMMIT_HASH}")