From a8ec728f80082086349e7791d9d13c4acf26cbed Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Tue, 22 Oct 2019 12:59:05 -0400 Subject: [PATCH 1/2] Set HAVE_GIT_VERSION to TRUE if it is a git repository 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. --- cmake/modules/ConfigCMake.cmake | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cmake/modules/ConfigCMake.cmake b/cmake/modules/ConfigCMake.cmake index 1fc32bd9ed3..726b6d97ef1 100644 --- a/cmake/modules/ConfigCMake.cmake +++ b/cmake/modules/ConfigCMake.cmake @@ -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 of 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 ( @@ -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 From ae69ecee28a29bb4281cd87b417d30ee9e130c41 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Tue, 22 Oct 2019 13:02:54 -0400 Subject: [PATCH 2/2] Typo --- cmake/modules/ConfigCMake.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/modules/ConfigCMake.cmake b/cmake/modules/ConfigCMake.cmake index 726b6d97ef1..a10c085d8f7 100644 --- a/cmake/modules/ConfigCMake.cmake +++ b/cmake/modules/ConfigCMake.cmake @@ -40,7 +40,7 @@ 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 of not +# 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)