Skip to content

Commit

Permalink
Update GitVersion.cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
jahnf authored Oct 13, 2023
1 parent f538dcd commit 6c400ae
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions cmake/modules/GitVersion.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ function(get_version_info prefix directory)
set(${prefix}_VERSION_ISDIRTY 0 PARENT_SCOPE)
set(${prefix}_VERSION_BUILDTYPE "${CMAKE_BUILD_TYPE}" PARENT_SCOPE)
set(${prefix}_VERSION_DATE_MONTH_YEAR "" PARENT_SCOPE)
if("${${prefix}_VERSION_DISTANCE_OFFSET}" STREQUEAL "")
set(${prefix}_VERSION_DISTANCE_OFFSET 0)
endif()

if("${${prefix}_OR_VERSION_MAJOR}" STREQUAL "")
set(${prefix}_OR_VERSION_MAJOR 0)
Expand Down Expand Up @@ -248,7 +251,9 @@ function(get_version_info prefix directory)
endif()

set(${prefix}_VERSION_FLAG ${${prefix}_VERSION_FLAG} PARENT_SCOPE)
set(${prefix}_VERSION_DISTANCE ${${prefix}_VERSION_DISTANCE} PARENT_SCOPE)

math(EXPR TOTAL_DISTANCE_ " ${${prefix}_VERSION_DISTANCE} + ${${prefix}_VERSION_DISTANCE_OFFSET}" DECIMAL)
set(${prefix}_VERSION_DISTANCE ${TOTAL_DISTANCE_} PARENT_SCOPE)

execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
RESULT_VARIABLE resultSH
Expand Down Expand Up @@ -352,6 +357,7 @@ function(add_version_info_custom_prefix target prefix directory)
set(VERSION_PATCH 0)
set(VERSION_FLAG unknown)
set(VERSION_DISTANCE 0)
set(VERSION_DISTANCE_OFFSET 0)
set(VERSION_SHORTHASH unknown)
set(VERSION_FULLHASH unknown)
set(VERSION_STRING "0.0-unknown.0")
Expand All @@ -378,7 +384,12 @@ function(add_version_info_custom_prefix target prefix directory)
if(TARGET_VTYPE)
set(${prefix}_FALLBACK_VERSION_TYPE ${TARGET_VTYPE})
endif()

get_target_property(TARGET_VDIST_OFFSET ${target} VERSION_DISTANCE_OFFSET)
if(TARGET_VDIST_OFFSET)
set(VERSION_DISTANCE_OFFSET ${TARGET_VDIST_OFFSET})
endif()
set(${prefix}_VERSION_DISTANCE_OFFSET ${VERSION_DISTANCE_OFFSET})

include(ArchiveVersionInfo_${prefix} OPTIONAL RESULT_VARIABLE ARCHIVE_VERSION_PRESENT)
if(ARCHIVE_VERSION_PRESENT AND ${prefix}_VERSION_SUCCESS)
message(STATUS "Info: Version information from archive file.")
Expand Down

0 comments on commit 6c400ae

Please sign in to comment.