mdbx-cmake: fix/refine git-fetch_version macro for old branches.

Change-Id: Ied5b7c839da75de065fd86ec46da7b391022c948
This commit is contained in:
Leonid Yuriev 2020-10-19 16:19:48 +03:00
parent 7001d971e1
commit 603e250745

View File

@ -113,23 +113,34 @@ macro(fetch_version name source_root_directory parent_scope)
message(FATAL_ERROR "Please install latest version of git ('show --no-patch --format=%H HEAD' failed)") message(FATAL_ERROR "Please install latest version of git ('show --no-patch --format=%H HEAD' failed)")
endif() endif()
execute_process(COMMAND ${GIT} tag --sort=-version:refname execute_process(COMMAND ${GIT} describe --tags --abbrev=0 "--match=v[0-9]*"
OUTPUT_VARIABLE tag_list OUTPUT_VARIABLE last_release_tag
OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_STRIP_TRAILING_WHITESPACE
WORKING_DIRECTORY ${source_root_directory} WORKING_DIRECTORY ${source_root_directory}
RESULT_VARIABLE rc) RESULT_VARIABLE rc)
if(rc) if(rc)
message(FATAL_ERROR "Please install latest version of git ('tag --sort=-version:refname' failed)") message(FATAL_ERROR "Please install latest version of git ('describe --tags --abbrev=0 --match=v[0-9]*' failed)")
endif() endif()
string(REGEX REPLACE "\n" ";" tag_list "${tag_list}") if (last_release_tag)
set(last_release_tag "") set(git_revlist_arg "${last_release_tag}..HEAD")
set(git_revlist_arg "HEAD") else()
foreach(tag IN LISTS tag_list) execute_process(COMMAND ${GIT} tag --sort=-version:refname
if(NOT last_release_tag) OUTPUT_VARIABLE tag_list
string(REGEX MATCH "^v[0-9]+(\.[0-9]+)+" last_release_tag "${tag}") OUTPUT_STRIP_TRAILING_WHITESPACE
set(git_revlist_arg "${tag}..HEAD") WORKING_DIRECTORY ${source_root_directory}
RESULT_VARIABLE rc)
if(rc)
message(FATAL_ERROR "Please install latest version of git ('tag --sort=-version:refname' failed)")
endif() endif()
endforeach(tag) string(REGEX REPLACE "\n" ";" tag_list "${tag_list}")
set(git_revlist_arg "HEAD")
foreach(tag IN LISTS tag_list)
if(NOT last_release_tag)
string(REGEX MATCH "^v[0-9]+(\.[0-9]+)+" last_release_tag "${tag}")
set(git_revlist_arg "${tag}..HEAD")
endif()
endforeach(tag)
endif()
execute_process(COMMAND ${GIT} rev-list --count "${git_revlist_arg}" execute_process(COMMAND ${GIT} rev-list --count "${git_revlist_arg}"
OUTPUT_VARIABLE ${name}_GIT_REVISION OUTPUT_VARIABLE ${name}_GIT_REVISION
OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_STRIP_TRAILING_WHITESPACE