Skip to content

Commit

Permalink
Set HAVE_GIT_VERSION to TRUE if it is a git repository (#1876)
Browse files Browse the repository at this point in the history
Check if the `.git` directory exists to determine if it's a git repository.

For a git repository, set HAVE_GIT_VERSION to TRUE, and enable the
`gmt_release` target.
  • Loading branch information
seisman authored Oct 22, 2019
1 parent d2c2368 commit 7a5cdf5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions cmake/modules/ConfigCMake.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,14 @@ 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})

# Check if it's a git repository or not
if (EXISTS ${GMT_SOURCE_DIR}/.git)
set (HAVE_GIT_VERSION TRUE)
endif (EXISTS ${GMT_SOURCE_DIR}/.git)

# Add the last git commit hash and date to the package version if this is a non-public release.
# A non-public release has a FALSE 'GMT_PUBLIC_RELEASE' variable in 'ConfigDefault.cmake'.
#set (HAVE_GIT_VERSION)
if (GIT_FOUND AND NOT GMT_PUBLIC_RELEASE)
# Get the last git commit hash
execute_process (
Expand All @@ -55,7 +60,6 @@ if (GIT_FOUND AND NOT GMT_PUBLIC_RELEASE)
message (STATUS "Unable to determine git commit hash for non-public release - ignoring.")
else (GIT_RETURN_CODE)
if (GIT_COMMIT_HASH)
set (HAVE_GIT_VERSION TRUE)
# For non-public release, add the last git commit hash and date
execute_process (
COMMAND ${GIT_EXECUTABLE} log -1 --date=short --pretty=format:%cd
Expand Down

0 comments on commit 7a5cdf5

Please sign in to comment.