mirror of
https://github.com/fralx/LimeReport.git
synced 2025-09-23 16:39:07 +03:00
Automate version generation
Version is now generated automatically based on git tags. Both cases are handled: building from git tree and building tarball downloaded from github. Works for qmake and cmake
This commit is contained in:
28
cmake/modules/GenerateVersionHeader.cmake
Normal file
28
cmake/modules/GenerateVersionHeader.cmake
Normal file
@@ -0,0 +1,28 @@
|
||||
find_package(Git)
|
||||
|
||||
if(GIT_EXECUTABLE)
|
||||
# Generate a git-describe version string from Git repository tags
|
||||
execute_process(
|
||||
COMMAND ${GIT_EXECUTABLE} describe --tags --dirty
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE GIT_DESCRIBE_VERSION
|
||||
RESULT_VARIABLE GIT_DESCRIBE_ERROR_CODE
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
if(NOT GIT_DESCRIBE_ERROR_CODE)
|
||||
set(GIT_VERSION ${GIT_DESCRIBE_VERSION})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Final fallback: Just use a bogus version string that is semantically older
|
||||
# than anything else and spit out a warning to the developer.
|
||||
if(NOT DEFINED GIT_VERSION)
|
||||
set(GIT_VERSION 0.0.0-unknown)
|
||||
message(WARNING "Failed to determine version from Git tags. Using default version \"${GIT_VERSION}\".")
|
||||
endif()
|
||||
|
||||
configure_file(
|
||||
${CMAKE_SOURCE_DIR}/limereport/version.h.in
|
||||
${CMAKE_BINARY_DIR}/limereport/version.h
|
||||
@ONLY)
|
||||
|
Reference in New Issue
Block a user