[cmake] fix version from git tag

only consider tags that conform to the format  'somestring1.2.3' as
valid tags
This commit is contained in:
akallabeth 2023-05-02 09:18:30 +02:00 committed by Martin Fleisz
parent 4859a5dfd4
commit 05edcbc357
2 changed files with 10 additions and 4 deletions

View File

@ -90,18 +90,21 @@ if ($ENV{BUILD_NUMBER})
endif()
set(WITH_LIBRARY_VERSIONING "ON")
set(VERSION_REGEX "^(.*)([0-9]+)\\.([0-9]+)\\.([0-9]+)-?(.*)")
set(RAW_VERSION_STRING "3.0.0-dev")
if(EXISTS "${PROJECT_SOURCE_DIR}/.source_tag")
file(READ ${PROJECT_SOURCE_DIR}/.source_tag RAW_VERSION_STRING)
elseif(USE_VERSION_FROM_GIT_TAG)
git_get_exact_tag(_GIT_TAG --tags --always)
if (NOT ${_GIT_TAG} STREQUAL "n/a")
set(RAW_VERSION_STRING ${_GIT_TAG})
string(REGEX MATCH ${VERSION_REGEX} FOUND_TAG "${_GIT_TAG}")
if (FOUND_TAG)
set(RAW_VERSION_STRING ${_GIT_TAG})
endif()
endif()
endif()
string(STRIP ${RAW_VERSION_STRING} RAW_VERSION_STRING)
set(VERSION_REGEX "^(.*)([0-9]+)\\.([0-9]+)\\.([0-9]+)-?(.*)")
string(REGEX REPLACE "${VERSION_REGEX}" "\\2" FREERDP_VERSION_MAJOR "${RAW_VERSION_STRING}")
string(REGEX REPLACE "${VERSION_REGEX}" "\\3" FREERDP_VERSION_MINOR "${RAW_VERSION_STRING}")
string(REGEX REPLACE "${VERSION_REGEX}" "\\4" FREERDP_VERSION_REVISION "${RAW_VERSION_STRING}")

View File

@ -120,18 +120,21 @@ if (NOT WIN32)
endif()
# Soname versioning
set(VERSION_REGEX "^(.*)([0-9]+)\\.([0-9]+)\\.([0-9]+)-?(.*)")
set(RAW_VERSION_STRING "3.0.0-dev")
if(EXISTS "${PROJECT_SOURCE_DIR}/.source_tag")
file(READ ${PROJECT_SOURCE_DIR}/.source_tag RAW_VERSION_STRING)
elseif(USE_VERSION_FROM_GIT_TAG)
git_get_exact_tag(_GIT_TAG --tags --always)
if (NOT ${_GIT_TAG} STREQUAL "n/a")
set(RAW_VERSION_STRING ${_GIT_TAG})
string(REGEX MATCH ${VERSION_REGEX} FOUND_TAG "${_GIT_TAG}")
if (FOUND_TAG)
set(RAW_VERSION_STRING ${_GIT_TAG})
endif()
endif()
endif()
string(STRIP ${RAW_VERSION_STRING} RAW_VERSION_STRING)
set(VERSION_REGEX "^(.*)([0-9]+)\\.([0-9]+)\\.([0-9]+)-?(.*)")
string(REGEX REPLACE "${VERSION_REGEX}" "\\2" WINPR_VERSION_MAJOR "${RAW_VERSION_STRING}")
string(REGEX REPLACE "${VERSION_REGEX}" "\\3" WINPR_VERSION_MINOR "${RAW_VERSION_STRING}")
string(REGEX REPLACE "${VERSION_REGEX}" "\\4" WINPR_VERSION_REVISION "${RAW_VERSION_STRING}")