1
0
mirror of https://github.com/jaredtao/TaoQuick.git synced 2025-02-06 21:48:24 +08:00
TaoQuick/cmake/taoVersion.cmake

38 lines
1.2 KiB
CMake
Raw Normal View History

2020-11-09 14:21:13 +08:00
find_package(Git)
if(Git_FOUND)
message("Git found: ${GIT_EXECUTABLE}")
endif()
set (REVISION "0000000000")
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-parse HEAD
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT_VARIABLE OUTPUT)
if (OUTPUT)
string(SUBSTRING ${OUTPUT} 0 10 REVISION)
endif()
message("REVISION ${REVISION}")
2020-11-10 13:55:51 +08:00
add_compile_definitions(TaoREVISIONSTR="${REVISION}")
2020-11-09 14:21:13 +08:00
set (TAG "0.0.0.0")
execute_process(
COMMAND ${GIT_EXECUTABLE} describe --abbrev=0 --tags
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
2020-11-11 13:14:00 +08:00
OUTPUT_VARIABLE OUTPUT)
if(OUTPUT)
string(STRIP ${OUTPUT} TAG)
endif()
2020-11-09 14:21:13 +08:00
message("TAG ${TAG}")
2020-11-10 00:41:40 +08:00
add_compile_definitions(TaoVer="${TAG}")
2020-11-09 19:12:54 +08:00
string(REPLACE "." ";" VERSION_LIST ${TAG})
list(GET VERSION_LIST 0 TAG_VERSION_MAJOR)
list(GET VERSION_LIST 1 TAG_VERSION_MINOR)
list(GET VERSION_LIST 2 TAG_VERSION_PATCH)
2020-11-10 00:41:40 +08:00
add_compile_definitions(TaoMAJ=${TAG_VERSION_MAJOR})
add_compile_definitions(TaoMIN=${TAG_VERSION_MINOR})
add_compile_definitions(TaoPAT=${TAG_VERSION_PATCH})
2020-11-09 19:12:54 +08:00
2020-11-11 13:14:00 +08:00
string(TIMESTAMP DateTime "%Y-%m-%d %H:%M:%S")
2020-11-10 00:41:40 +08:00
add_compile_definitions(TaoDATETIME="${DateTime}")
add_compile_definitions(CXX_COMPILER_ID="${CMAKE_CXX_COMPILER_ID}")