This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
tango-tfe/cmake/Version.cmake
2019-08-30 15:46:08 +08:00

50 lines
1.8 KiB
CMake

# Using autorevision.sh to generate version information
set(__SOURCE_AUTORESIVISION ${CMAKE_SOURCE_DIR}/autorevision.sh)
set(__AUTORESIVISION ${CMAKE_BINARY_DIR}/autorevision.sh)
set(__VERSION_CACHE ${CMAKE_SOURCE_DIR}/version.txt)
set(__VERSION_CONFIG ${CMAKE_BINARY_DIR}/version.cmake)
file(COPY ${__SOURCE_AUTORESIVISION} DESTINATION ${CMAKE_BINARY_DIR}
FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE)
# execute autorevision.sh to generate version information
execute_process(COMMAND ${__AUTORESIVISION} -t cmake -o ${__VERSION_CACHE} OUTPUT_FILE ${__VERSION_CONFIG})
include(${__VERSION_CONFIG})
# extract major, minor, patch version from git tag
string(REGEX REPLACE "^v([0-9]+)\\..*" "\\1" TFE_VERSION_MAJOR "${VCS_TAG}")
string(REGEX REPLACE "^v[0-9]+\\.([0-9]+).*" "\\1" TFE_VERSION_MINOR "${VCS_TAG}")
string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" TFE_VERSION_PATCH "${VCS_TAG}")
string(REGEX REPLACE "[T\\:\\+\\-]" "" TFE_VERSION_DATE "${VCS_DATE}")
if(TFE_VERSION_DAILY_BUILD)
set(TFE_VERSION_PATCH ${TFE_VERSION_PATCH}.${TFE_VERSION_DATE})
endif()
if(NOT TFE_VERSION_MAJOR)
set(TFE_VERSION_MAJOR 3)
endif()
if(NOT TFE_VERSION_MINOR)
set(TFE_VERSION_MINOR 0)
endif()
if(NOT TFE_VERSION_PATCH)
set(TFE_VERSION_PATCH 0)
endif()
set(TFE_DESCRIBE "${VCS_SHORT_HASH}")
set(TFE_VERSION "${TFE_VERSION_MAJOR}.${TFE_VERSION_MINOR}.${TFE_VERSION_PATCH}")
set(TFE_GIT_VERSION "${TFE_VERSION_MAJOR}.${TFE_VERSION_MINOR}.${TFE_VERSION_PATCH}-${TFE_DESCRIBE}")
# Replace .- with _
string(REGEX REPLACE "[\\.\\-]" "_" TFE_VAR_VERSION "${TFE_GIT_VERSION}")
# print information
message(STATUS "Welcome to Tango Frontend Engine, Version: ${TFE_GIT_VERSION}")
add_definitions(-DTFE_GIT_VERSION=\"${TFE_GIT_VERSION}\")
add_definitions(-DTFE_VAR_VERSION=${TFE_VAR_VERSION})