|
18 | 18 | #
|
19 | 19 | ################################################################################
|
20 | 20 |
|
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 |
| -# |
27 | 21 | # If the command line client executable is found the macro
|
28 | 22 | # GIT_WC_INFO(<dir> <var-prefix>)
|
29 | 23 | # is defined to extract information of a git working copy at
|
|
60 | 54 | # endif()
|
61 | 55 | #
|
62 | 56 |
|
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 () |
66 | 62 |
|
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}) |
80 | 69 |
|
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) |
87 | 70 |
|
88 |
| -if(GIT_EXECUTABLE) |
| 71 | +if(GIT_FOUND) |
89 | 72 | execute_process(COMMAND ${GIT_EXECUTABLE} --version
|
90 | 73 | OUTPUT_VARIABLE git_version
|
91 | 74 | ERROR_QUIET
|
@@ -179,10 +162,4 @@ if(GIT_EXECUTABLE)
|
179 | 162 | endif()
|
180 | 163 |
|
181 | 164 | 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