Skip to content

Commit

Permalink
Update cmake for git version
Browse files Browse the repository at this point in the history
  • Loading branch information
Jackarain committed Jun 5, 2024
1 parent 461aded commit b5debaa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,12 @@ option(ENABLE_LINKE_TO_LIBATOMIC "link to libatomic.so - some platform requires
if (ENABLE_GIT_VERSION)
find_package(Git)
gitGetVersion(${CMAKE_CURRENT_SOURCE_DIR} proxy)
set(VERSION_GIT ${proxy_WC_REVISION_HASH})
string(TIMESTAMP PVERSION "${VERSION_GIT} (%Y-%m-%d %H:%M:%S)")
string(STRIP "${proxy_WC_REVISION_HASH}" VERSION_GIT)
if (VERSION_GIT STREQUAL "")
string(TIMESTAMP PVERSION "(%Y-%m-%d %H:%M:%S)")
else()
string(TIMESTAMP PVERSION "${VERSION_GIT} (%Y-%m-%d %H:%M:%S)")
endif()
message(STATUS "Git Version: ${PVERSION}")
endif()

Expand Down
2 changes: 1 addition & 1 deletion cmake/FindGit.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ find_package_handle_standard_args(Git DEFAULT_MSG GIT_EXECUTABLE)

function(gitGetVersion source_dir prefix)
if(GIT_FOUND)
GIT_WC_INFO(${source_dir} ${prefix})
if ("${GIT_error}" STREQUAL "")
GIT_WC_INFO(${source_dir} ${prefix})
if(NOT ${prefix}_WC_REVISION_HASH)
set(${prefix}_WC_REVISION_HASH "n/a")
endif()
Expand Down

0 comments on commit b5debaa

Please sign in to comment.