Fix git log in CMake for older Git

This commit is contained in:
Christian W. Zuckschwerdt 2019-03-05 10:19:19 +01:00
parent fc8734e382
commit 4c2748bb5d

View file

@ -158,13 +158,18 @@ function(git_timestamp _var)
return()
endif()
execute_process(COMMAND ${GIT_EXECUTABLE} log -1 --format=%cI ${hash} ${ARGN}
execute_process(COMMAND ${GIT_EXECUTABLE} log -1 --format=%ci ${hash} ${ARGN}
WORKING_DIRECTORY ${GIT_DIR}
RESULT_VARIABLE res
OUTPUT_VARIABLE out
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(res EQUAL 0)
# older Git does not have %cI, create ISO8601 from %ci
string(SUBSTRING ${out} 0 10 date)
string(SUBSTRING ${out} 10 -1 time)
string(REPLACE " " "" time ${time})
set(out "${date}T${time}")
set(${_var}_ISO ${out} PARENT_SCOPE)
string(REGEX REPLACE "[-T:]" "" out ${out})
string(SUBSTRING ${out} 0 12 out)