diff --git a/CMakeLists.txt b/CMakeLists.txt index fbce2a4..fef3d43 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,13 +10,19 @@ EXECUTE_PROCESS(COMMAND git describe --tags --always --dirty=-dev if ("${GIT_TAG}" STREQUAL "") STRING(TIMESTAMP COMPILE_TIME %Y-%m-%d_%H:%M:%S) - SET(GIT_TAG ${COMPILE_TIME}) + SET(GIT_VERSION ${COMPILE_TIME}) else () + EXECUTE_PROCESS(COMMAND git rev-parse --short HEAD + OUTPUT_VARIABLE GIT_HASH) + STRING(REGEX REPLACE "\n$" "" GIT_TAG ${GIT_TAG}) + STRING(REGEX REPLACE "\n$" "" GIT_HASH ${GIT_HASH}) + + SET(GIT_VERSION ${GIT_TAG}_${GIT_HASH}) endif () -MESSAGE("Version: " ${GIT_TAG}) +MESSAGE("Version: " ${GIT_VERSION}) ADD_SUBDIRECTORY(srcs) ADD_SUBDIRECTORY(srcs/libs) diff --git a/srcs/libs/CMakeLists.txt b/srcs/libs/CMakeLists.txt index 0f81a35..aef0347 100644 --- a/srcs/libs/CMakeLists.txt +++ b/srcs/libs/CMakeLists.txt @@ -23,7 +23,7 @@ AUX_SOURCE_DIRECTORY(hardware C_SRC) SET(CMAKE_C_STANDARD 99) -ADD_DEFINITIONS(-DBUILD_VERSION="${GIT_TAG}") +ADD_DEFINITIONS(-DBUILD_VERSION="${GIT_VERSION}") LINK_LIBRARIES(${COMMON_LIBS}) ADD_LIBRARY(${LIB_PROJECT_TARGET} ${C_SRC} ${C_HEADS}) \ No newline at end of file