Skip to content

Commit 5289838

Browse files
committed
Use CMake's FindGit.
Replaced code in FindGitInfo module with calling the upstream FindGit module.
1 parent 532f30d commit 5289838

File tree

1 file changed

+13
-36
lines changed

1 file changed

+13
-36
lines changed

cmake/FindGitInfo.cmake

+13-36
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,6 @@
1818
#
1919
################################################################################
2020

21-
#
22-
# The module defines the following variables:
23-
# GIT_EXECUTABLE - path to git command line client
24-
# GIT_FOUND - true if the command line client was found
25-
# GIT_VERSION_STRING - the version of git found (since CMake 2.8.8)
26-
#
2721
# If the command line client executable is found the macro
2822
# GIT_WC_INFO(<dir> <var-prefix>)
2923
# is defined to extract information of a git working copy at
@@ -60,32 +54,21 @@
6054
# endif()
6155
#
6256

63-
# Look for 'git' or 'eg' (easy git)
64-
#
65-
set(git_names git eg)
57+
# Look for git. Respect the quiet and required flags passed to this module.
58+
set(FIND_QUIETLY_FLAG "")
59+
if (DEFINED GitInfo_FIND_QUIETLY)
60+
set(FIND_QUIETLY_FLAG "QUIET")
61+
endif ()
6662

67-
# Prefer .cmd variants on Windows unless running in a Makefile
68-
# in the MSYS shell.
69-
#
70-
if(WIN32)
71-
if(NOT CMAKE_GENERATOR MATCHES "MSYS")
72-
# Note: Due to a bug in 'git.cmd' preventing it from returning the exit code of 'git',
73-
# we excluded it from the list of executables to search.
74-
# See http://code.google.com/p/msysgit/issues/detail?id=428
75-
# TODO Check if 'git' exists, get the associated version, if the corresponding version
76-
# is known to have a working version of 'git.cmd', use it.
77-
set(git_names git eg.cmd eg)
78-
endif()
79-
endif()
63+
set(FIND_REQUIRED_FLAG "")
64+
if (DEFINED GitInfo_FIND_REQUIRED)
65+
set(FIND_REQUIRED_FLAG "REQUIRED")
66+
endif ()
67+
68+
find_package(Git ${FIND_QUIETLY_FLAG} ${FIND_REQUIRED_FLAG})
8069

81-
find_program(GIT_EXECUTABLE ${git_names}
82-
PATHS
83-
"C:/Program Files/Git/bin"
84-
"C:/Program Files (x86)/Git/bin"
85-
DOC "git command line client")
86-
mark_as_advanced(GIT_EXECUTABLE)
8770

88-
if(GIT_EXECUTABLE)
71+
if(GIT_FOUND)
8972
execute_process(COMMAND ${GIT_EXECUTABLE} --version
9073
OUTPUT_VARIABLE git_version
9174
ERROR_QUIET
@@ -179,10 +162,4 @@ if(GIT_EXECUTABLE)
179162
endif()
180163

181164
endmacro(GIT_WC_INFO)
182-
endif(GIT_EXECUTABLE)
183-
184-
# Handle the QUIETLY and REQUIRED arguments and set GIT_FOUND to TRUE if
185-
# all listed variables are TRUE
186-
187-
include(FindPackageHandleStandardArgs)
188-
find_package_handle_standard_args(Git DEFAULT_MSG GIT_EXECUTABLE)
165+
endif(GIT_FOUND)

0 commit comments

Comments
 (0)