Skip to content

Commit

Permalink
cmake: Set GMT_BUILD_DATE to the current date or the last commit date (
Browse files Browse the repository at this point in the history
  • Loading branch information
seisman committed May 31, 2024
1 parent e0bfaa0 commit 5e53ea3
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions cmake/modules/ConfigCMake.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,6 @@ endif (NOT CMAKE_BUILD_TYPE)
# Here we change it to add the git commit hash for non-public releases
set (GMT_PACKAGE_VERSION_WITH_GIT_REVISION ${GMT_PACKAGE_VERSION})

# ...
set (GMT_BUILD_DATE ${GMT_BUILD_DATE})

# Check if it's a git repository or not
if (EXISTS ${GMT_SOURCE_DIR}/.git)
set (HAVE_GIT_VERSION TRUE)
Expand Down Expand Up @@ -95,11 +92,15 @@ if (GIT_FOUND AND HAVE_GIT_VERSION AND NOT GMT_PUBLIC_RELEASE)
endif (GIT_RETURN_CODE)
endif (GIT_FOUND AND HAVE_GIT_VERSION AND NOT GMT_PUBLIC_RELEASE)

execute_process (COMMAND ${GIT_EXECUTABLE} log -1 --date=short --pretty=format:%cd
WORKING_DIRECTORY ${GMT_SOURCE_DIR}
OUTPUT_VARIABLE GMT_BUILD_DATE
OUTPUT_STRIP_TRAILING_WHITESPACE)
string(REPLACE "-" "." GMT_BUILD_DATE "${GMT_BUILD_DATE}")
# Set the GMT building date
string(TIMESTAMP GMT_BUILD_DATE "%Y.%m.%d" UTC) # Default to current year.
if (HAVE_GIT_VERSION)
execute_process (COMMAND ${GIT_EXECUTABLE} log -1 --date=short --pretty=format:%cd
WORKING_DIRECTORY ${GMT_SOURCE_DIR}
OUTPUT_VARIABLE GMT_BUILD_DATE
OUTPUT_STRIP_TRAILING_WHITESPACE)
string(REPLACE "-" "." GMT_BUILD_DATE "${GMT_BUILD_DATE}")
endif (HAVE_GIT_VERSION)

# apply license restrictions
if (LICENSE_RESTRICTED) # on
Expand Down

0 comments on commit 5e53ea3

Please sign in to comment.