mirror of
https://github.com/fralx/LimeReport.git
synced 2024-12-24 00:33:02 +03:00
b534c2bec0
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
29 lines
877 B
CMake
29 lines
877 B
CMake
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)
|
|
|