Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake: Set GMT_BUILD_DATE to the current date or the last commit date #8501

Merged
merged 1 commit into from
May 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading