From: Matthias Maier Date: Thu, 17 Feb 2022 08:16:41 +0000 (-0600) Subject: CMake: also record git commit timestamp X-Git-Tag: v9.4.0-rc1~464^2~4 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=28e5f5b8029d13ee6fce9ab0864b91163fa4e1e5;p=dealii.git CMake: also record git commit timestamp --- diff --git a/cmake/macros/macro_deal_ii_query_git_information.cmake b/cmake/macros/macro_deal_ii_query_git_information.cmake index 7eba3937da..e3703c6bee 100644 --- a/cmake/macros/macro_deal_ii_query_git_information.cmake +++ b/cmake/macros/macro_deal_ii_query_git_information.cmake @@ -37,6 +37,7 @@ # PREFIX_GIT_REVISION # PREFIX_GIT_SHORTREV # PREFIX_GIT_TAG +# PREFIX_GIT_TIMESTAMP # MACRO(DEAL_II_QUERY_GIT_INFORMATION) @@ -76,19 +77,32 @@ MACRO(DEAL_II_QUERY_GIT_INFORMATION) # # Query for revision: # + # Format options for git log: + # %H - the full sha1 hash of the commit, aka "revision" + # %h - the abbreviated sha1 hash of the commit, aka "shortrev" + # %cd - the commit date (for which we use the strict iso date format) + # EXECUTE_PROCESS( - COMMAND ${GIT_EXECUTABLE} log -n 1 --pretty=format:"%H %h" + COMMAND ${GIT_EXECUTABLE} log -n 1 --pretty=format:"%H\;%h\;%cd" --date=iso-strict WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE _info RESULT_VARIABLE _result OUTPUT_STRIP_TRAILING_WHITESPACE ) IF(${_result} EQUAL 0) - STRING(REGEX REPLACE "^\"([^ ]+) ([^ ]+)\"$" + STRING(REGEX REPLACE "^\"([^;]+);([^;]+);([^;]+)\"$" "\\1" ${_prefix}GIT_REVISION "${_info}") - STRING(REGEX REPLACE "^\"([^ ]+) ([^ ]+)\"$" + STRING(REGEX REPLACE "^\"([^;]+);([^;]+);([^;]+)\"$" "\\2" ${_prefix}GIT_SHORTREV "${_info}") + STRING(REGEX REPLACE "^\"([^;]+);([^;]+);([^;]+)\"$" + "\\3" ${_prefix}GIT_TIMESTAMP "${_info}") + + # + # Replace "T" by a space in order to have the same output as + # $ date --rfc-3339=seconds" + # + STRING(REPLACE "T" " " ${_prefix}GIT_TIMESTAMP "${${_prefix}GIT_TIMESTAMP}") ENDIF() #