Skip to content

Commit 7a5cdf5

Browse files
authored
Set HAVE_GIT_VERSION to TRUE if it is a git repository (#1876)
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.
1 parent d2c2368 commit 7a5cdf5

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

cmake/modules/ConfigCMake.cmake

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,14 @@ endif (NOT CMAKE_BUILD_TYPE)
3939

4040
# Here we change it to add the git commit hash for non-public releases
4141
set (GMT_PACKAGE_VERSION_WITH_GIT_REVISION ${GMT_PACKAGE_VERSION})
42+
43+
# Check if it's a git repository or not
44+
if (EXISTS ${GMT_SOURCE_DIR}/.git)
45+
set (HAVE_GIT_VERSION TRUE)
46+
endif (EXISTS ${GMT_SOURCE_DIR}/.git)
47+
4248
# Add the last git commit hash and date to the package version if this is a non-public release.
4349
# A non-public release has a FALSE 'GMT_PUBLIC_RELEASE' variable in 'ConfigDefault.cmake'.
44-
#set (HAVE_GIT_VERSION)
4550
if (GIT_FOUND AND NOT GMT_PUBLIC_RELEASE)
4651
# Get the last git commit hash
4752
execute_process (
@@ -55,7 +60,6 @@ if (GIT_FOUND AND NOT GMT_PUBLIC_RELEASE)
5560
message (STATUS "Unable to determine git commit hash for non-public release - ignoring.")
5661
else (GIT_RETURN_CODE)
5762
if (GIT_COMMIT_HASH)
58-
set (HAVE_GIT_VERSION TRUE)
5963
# For non-public release, add the last git commit hash and date
6064
execute_process (
6165
COMMAND ${GIT_EXECUTABLE} log -1 --date=short --pretty=format:%cd

0 commit comments

Comments
 (0)