Extract version from file or git tag.

This commit is contained in:
Armin Novak 2017-11-08 14:22:38 +01:00
parent e6e5daea08
commit e4cf045860
2 changed files with 23 additions and 5 deletions

View File

@ -67,6 +67,7 @@ include(CheckCXXCompilerFlag)
include(GNUInstallDirsWrapper) include(GNUInstallDirsWrapper)
include(CMakePackageConfigHelpers) include(CMakePackageConfigHelpers)
include(InstallFreeRDPMan) include(InstallFreeRDPMan)
include(GetGitRevisionDescription)
# Soname versioning # Soname versioning
set(BUILD_NUMBER 0) set(BUILD_NUMBER 0)
@ -74,10 +75,24 @@ if ($ENV{BUILD_NUMBER})
set(BUILD_NUMBER $ENV{BUILD_NUMBER}) set(BUILD_NUMBER $ENV{BUILD_NUMBER})
endif() endif()
set(WITH_LIBRARY_VERSIONING "ON") set(WITH_LIBRARY_VERSIONING "ON")
set(FREERDP_VERSION_MAJOR "2")
set(FREERDP_VERSION_MINOR "0") set(RAW_VERSTION_STRING "2.0.0-dev")
set(FREERDP_VERSION_REVISION "0") if(EXISTS "${CMAKE_SOURCE_DIR}/.source_tag")
set(FREERDP_VERSION_SUFFIX "dev") file(READ ${CMAKE_SOURCE_DIR}/.source_tag RAW_VERSTION_STRING)
elseif(USE_VERSION_FROM_GIT_TAG)
git_get_exact_tag(_GIT_TAG --tags --always)
if (NOT ${_GIT_TAG} STREQUAL "n/a")
set(RAW_VERSTION_STRING ${_GIT_TAG})
endif()
endif()
string(STRIP ${RAW_VERSTION_STRING} RAW_VERSTION_STRING)
set(VERSION_REGEX "^.?([0-9]+)\\.([0-9]+)\\.([0-9]+)-?(.*)")
string(REGEX REPLACE "${VERSION_REGEX}" "\\1" FREERDP_VERSION_MAJOR "${RAW_VERSTION_STRING}")
string(REGEX REPLACE "${VERSION_REGEX}" "\\2" FREERDP_VERSION_MINOR "${RAW_VERSTION_STRING}")
string(REGEX REPLACE "${VERSION_REGEX}" "\\3" FREERDP_VERSION_REVISION "${RAW_VERSTION_STRING}")
string(REGEX REPLACE "${VERSION_REGEX}" "\\4" FREERDP_VERSION_SUFFIX "${RAW_VERSTION_STRING}")
set(FREERDP_API_VERSION "${FREERDP_VERSION_MAJOR}") set(FREERDP_API_VERSION "${FREERDP_VERSION_MAJOR}")
set(FREERDP_VERSION "${FREERDP_VERSION_MAJOR}.${FREERDP_VERSION_MINOR}.${FREERDP_VERSION_REVISION}") set(FREERDP_VERSION "${FREERDP_VERSION_MAJOR}.${FREERDP_VERSION_MINOR}.${FREERDP_VERSION_REVISION}")
if (FREERDP_VERSION_SUFFIX) if (FREERDP_VERSION_SUFFIX)
@ -85,6 +100,8 @@ if (FREERDP_VERSION_SUFFIX)
else() else()
set(FREERDP_VERSION_FULL "${FREERDP_VERSION}") set(FREERDP_VERSION_FULL "${FREERDP_VERSION}")
endif() endif()
message("FREERDP_VERSION=${FREERDP_VERSION_FULL}")
set(FREERDP_INCLUDE_DIR "include/freerdp${FREERDP_VERSION_MAJOR}/") set(FREERDP_INCLUDE_DIR "include/freerdp${FREERDP_VERSION_MAJOR}/")
# Compatibility options # Compatibility options
@ -117,7 +134,6 @@ if(EXISTS "${CMAKE_SOURCE_DIR}/.source_version" )
string(STRIP ${GIT_REVISION} GIT_REVISION) string(STRIP ${GIT_REVISION} GIT_REVISION)
else() else()
include(GetGitRevisionDescription)
git_get_exact_tag(GIT_REVISION --tags --always) git_get_exact_tag(GIT_REVISION --tags --always)
if (${GIT_REVISION} STREQUAL "n/a") if (${GIT_REVISION} STREQUAL "n/a")

View File

@ -132,6 +132,8 @@ option(WITH_DEBUG_SYMBOLS "Pack debug symbols to installer" OFF)
option(WITH_CCACHE "Use ccache support if available" ON) option(WITH_CCACHE "Use ccache support if available" ON)
option(WITH_ICU "Use ICU for unicode conversion" OFF) option(WITH_ICU "Use ICU for unicode conversion" OFF)
option(USE_VERSION_FROM_GIT_TAG "Extract FreeRDP version from git tag." OFF)
if(ANDROID) if(ANDROID)
include(ConfigOptionsAndroid) include(ConfigOptionsAndroid)
endif(ANDROID) endif(ANDROID)