Append Git revision to version
* Append Git revision and ID of latest commit to version displayed via --help * Can be turned off via option * Has no effect if the source dir is not a Git checkout or Git is not installed * Implements https://github.com/Martchus/tageditor/issues/13
This commit is contained in:
parent
91e5a8b0b0
commit
412e725309
|
@ -45,6 +45,7 @@ target_compile_definitions(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}
|
|||
)
|
||||
set_target_properties(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX} PROPERTIES
|
||||
APP_NAME "${META_APP_NAME}"
|
||||
VERSION "${META_APP_VERSION}"
|
||||
CXX_STANDARD "${META_CXX_STANDARD}"
|
||||
LINK_SEARCH_START_STATIC ${STATIC_LINKAGE}
|
||||
LINK_SEARCH_END_STATIC ${STATIC_LINKAGE}
|
||||
|
|
|
@ -61,9 +61,29 @@ if(HAS_PARENT)
|
|||
endif()
|
||||
endif()
|
||||
|
||||
# determine version
|
||||
set(META_APP_VERSION ${META_VERSION_MAJOR}.${META_VERSION_MINOR}.${META_VERSION_PATCH})
|
||||
option(APPEND_GIT_REVISION "whether the build script should attempt to append the git revision and latest commit to the version displayed via --help" ON)
|
||||
if(APPEND_GIT_REVISION)
|
||||
execute_process(
|
||||
COMMAND git rev-list --count HEAD
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
OUTPUT_VARIABLE META_GIT_REV_COUNT
|
||||
)
|
||||
execute_process(
|
||||
COMMAND git rev-parse --short HEAD
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
OUTPUT_VARIABLE META_GIT_LAST_COMMIT_ID
|
||||
)
|
||||
string(REPLACE "\n" "" META_GIT_REV_COUNT "${META_GIT_REV_COUNT}")
|
||||
string(REPLACE "\n" "" META_GIT_LAST_COMMIT_ID "${META_GIT_LAST_COMMIT_ID}")
|
||||
if(META_GIT_REV_COUNT AND META_GIT_LAST_COMMIT_ID)
|
||||
set(META_APP_VERSION ${META_APP_VERSION}-${META_GIT_REV_COUNT}.${META_GIT_LAST_COMMIT_ID})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# stringify the meta data
|
||||
set(META_PROJECT_NAME_STR "\"${META_PROJECT_NAME}\"")
|
||||
set(META_APP_VERSION ${META_VERSION_MAJOR}.${META_VERSION_MINOR}.${META_VERSION_PATCH})
|
||||
set(META_APP_NAME_STR "\"${META_APP_NAME}\"")
|
||||
set(META_APP_AUTHOR_STR "\"${META_APP_AUTHOR}\"")
|
||||
set(META_APP_URL_STR "\"${META_APP_URL}\"")
|
||||
|
|
|
@ -135,7 +135,7 @@ if(BUILD_SHARED_LIBS)
|
|||
)
|
||||
set_target_properties(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX} PROPERTIES
|
||||
APP_NAME "${META_APP_NAME}"
|
||||
VERSION "${META_VERSION_MAJOR}.${META_VERSION_MINOR}.${META_VERSION_PATCH}"
|
||||
VERSION "${META_APP_VERSION}"
|
||||
SOVERSION "${META_SOVERSION}"
|
||||
CXX_STANDARD "${META_CXX_STANDARD}"
|
||||
LINK_SEARCH_START_STATIC ${STATIC_LINKAGE}
|
||||
|
|
|
@ -38,6 +38,10 @@ None of these are enabled or set by default, unless stated otherwise.
|
|||
(sets `_GLIBCXX_USE_CXX11_ABI=0`)
|
||||
* `EXCLUDE_TESTS_FROM_ALL=ON/OFF`: excludes tests from the all target
|
||||
(enabled by default)
|
||||
* `APPEND_GIT_REVISION=ON/OFF`: whether the build script should attempt to
|
||||
append the Git revision and the latest commit ID to the version displayed
|
||||
via --help (enabled by default but has no effect when the source directory is
|
||||
no Git checkout or Git is not installed)
|
||||
|
||||
#### Windows specific
|
||||
* `USE_NATIVE_FILE_BUFFER=ON/OFF`: use native function to open file streams
|
||||
|
|
Loading…
Reference in New Issue