From 9dc4c432ea1b602a4dd63d884096be0479296730 Mon Sep 17 00:00:00 2001 From: Magnus Jacobsson Date: Mon, 29 Jun 2020 08:06:44 +0200 Subject: [PATCH] Generate build date in UTC also in CMake This is what autogen.sh does. --- CMakeLists.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 855d9361f..622901629 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -155,8 +155,12 @@ else() endif() # Set GRAPHVIZ_VERSION_BUILD to time of last commit, or to 0 if that fails. +if (DEFINED ENV{TZ}) + set(TZ_ORIG $ENV{TZ}) +endif() +set(ENV{TZ} UTC) execute_process( - COMMAND "${GIT_EXECUTABLE}" log -n 1 --format=%cd --date=format:%Y%m%d.%H%M + COMMAND "${GIT_EXECUTABLE}" log -n 1 --format=%cd --date=format-local:%Y%m%d.%H%M WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" RESULT_VARIABLE git_result OUTPUT_VARIABLE GRAPHVIZ_VERSION_BUILD @@ -164,6 +168,7 @@ execute_process( OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_STRIP_TRAILING_WHITESPACE ) +set(ENV{TZ} ${TZ_ORIG}) if(NOT git_result EQUAL 0) message(WARNING "Failed to set build version: ${git_error}") set(GRAPHVIZ_VERSION_BUILD 0) -- 2.40.0