Use git describe to express version in terms of closest tag.

This commit is contained in:
Aaron van Geffen 2018-06-12 00:25:04 +02:00
parent e39f89c6ad
commit 56250b43ab
3 changed files with 31 additions and 8 deletions

View file

@ -47,6 +47,16 @@ if (PORTABLE OR WIN32)
set(CMAKE_INSTALL_RPATH "$ORIGIN")
endif ()
# Describe current version in terms of closest tag
execute_process(
COMMAND git describe HEAD
COMMAND sed -E "s/-g.+$//"
WORKING_DIRECTORY ${ROOT_DIR}
OUTPUT_VARIABLE OPENRCT2_VERSION_TAG
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
)
# Define current git branch
execute_process(
COMMAND git rev-parse --abbrev-ref HEAD

View file

@ -168,6 +168,9 @@ endif ()
# definitions: Version.cpp and Crash/Platform.cpp
set_property(SOURCE ${CMAKE_CURRENT_LIST_DIR}/Version.cpp
${CMAKE_CURRENT_LIST_DIR}/Crash/Platform.cpp PROPERTY
COMPILE_DEFINITIONS OPENRCT2_VERSION_TAG="${OPENRCT2_VERSION_TAG}")
set_property(SOURCE ${CMAKE_CURRENT_LIST_DIR}/Version.cpp
${CMAKE_CURRENT_LIST_DIR}/Crash/Platform.cpp APPEND PROPERTY
COMPILE_DEFINITIONS OPENRCT2_BRANCH="${OPENRCT2_BRANCH}")
if (NOT OPENRCT2_COMMIT_SHA1_SHORT STREQUAL "HEAD")
set_property(SOURCE ${CMAKE_CURRENT_LIST_DIR}/Version.cpp

View file

@ -22,17 +22,27 @@
#endif
const char gVersionInfoFull[] =
OPENRCT2_NAME ", v" OPENRCT2_VERSION
#ifdef OPENRCT2_BRANCH
"-" OPENRCT2_BRANCH
OPENRCT2_NAME ", "
#ifdef OPENRCT2_VERSION_TAG
OPENRCT2_VERSION_TAG
#else
"v" OPENRCT2_VERSION
#endif
#ifdef OPENRCT2_COMMIT_SHA1_SHORT
" build " OPENRCT2_COMMIT_SHA1_SHORT
#if defined(OPENRCT2_BRANCH) || defined(OPENRCT2_COMMIT_SHA1_SHORT) || !defined(NDEBUG)
" ("
#if defined(OPENRCT2_BRANCH) && defined(OPENRCT2_COMMIT_SHA1_SHORT)
OPENRCT2_COMMIT_SHA1_SHORT " on " OPENRCT2_BRANCH
#elif defined(OPENRCT2_COMMIT_SHA1_SHORT)
OPENRCT2_COMMIT_SHA1_SHORT
#elif defined(OPENRCT2_BRANCH)
OPENRCT2_BRANCH
#endif
#ifndef NDEBUG
", DEBUG"
#endif
")"
#endif
#ifdef OPENRCT2_BUILD_SERVER
" provided by " OPENRCT2_BUILD_SERVER
#endif
#ifndef NDEBUG
" (DEBUG)"
#endif
;