REM:
1. 增加git版本详细信息
This commit is contained in:
huangxin 2022-06-28 17:45:56 +08:00
parent 990f60b160
commit d4003c0a88
2 changed files with 9 additions and 3 deletions

View File

@ -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)

View File

@ -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})