cmake: rework patch version computation
This commit is contained in:
committed by
Corentin Le Molgat
parent
4f9d32fd6a
commit
f01debfd27
@@ -17,7 +17,7 @@ function(get_patch_from_git VERSION_PATCH VERSION_MAJOR)
|
||||
message(STATUS "Did not find git package.")
|
||||
set(PATCH 9999)
|
||||
else()
|
||||
# If no tags can be found, it is a git shallow clone
|
||||
# If no tags can be found, it is a git shallow clone or a new major
|
||||
execute_process(COMMAND
|
||||
${GIT_EXECUTABLE} rev-list --count v${VERSION_MAJOR}.0..HEAD
|
||||
RESULT_VARIABLE RESULT_VAR
|
||||
@@ -25,8 +25,20 @@ function(get_patch_from_git VERSION_PATCH VERSION_MAJOR)
|
||||
ERROR_QUIET
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
if(RESULT_VAR) # since 0 is success, need invert it
|
||||
message(STATUS "Did not be able to compute patch from v${VERSION_MAJOR}.0.")
|
||||
set(PATCH 9999)
|
||||
message(STATUS "Did not be able to compute patch from 'v${VERSION_MAJOR}.0'.")
|
||||
execute_process(COMMAND
|
||||
${GIT_EXECUTABLE} rev-parse --is-shallow-repository
|
||||
OUTPUT_VARIABLE IS_SHALLOW_VAR
|
||||
ERROR_QUIET
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
if(${IS_SHALLOW_VAR} MATCHES "false")
|
||||
message(STATUS "Repo is not shallow, use 0 as patch.")
|
||||
set(PATCH 0)
|
||||
else()
|
||||
message(STATUS "Repo is shallow, use 9999 as patch.")
|
||||
set(PATCH 9999)
|
||||
endif()
|
||||
endif()
|
||||
STRING(STRIP PATCH ${PATCH})
|
||||
STRING(REGEX REPLACE "\n$" "" PATCH ${PATCH})
|
||||
|
||||
Reference in New Issue
Block a user