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:
@@ -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}")
|
||||
|
||||
Reference in New Issue
Block a user