]> granicus.if.org Git - icinga2/blob - cmake/FindGit.cmake
Update INSTALL file.
[icinga2] / cmake / FindGit.cmake
1 #.rst:
2 # FindGit
3 # -------
4 #
5 #
6 #
7 # The module defines the following variables:
8 #
9 # ::
10 #
11 #    GIT_EXECUTABLE - path to git command line client
12 #    GIT_FOUND - true if the command line client was found
13 #    GIT_VERSION_STRING - the version of git found (since CMake 2.8.8)
14 #
15 # Example usage:
16 #
17 # ::
18 #
19 #    find_package(Git)
20 #    if(GIT_FOUND)
21 #      message("git found: ${GIT_EXECUTABLE}")
22 #    endif()
23
24 #=============================================================================
25 # Copyright 2010 Kitware, Inc.
26 # Copyright 2012 Rolf Eike Beer <eike@sf-mail.de>
27 #
28 # Distributed under the OSI-approved BSD License (the "License");
29 # see accompanying file Copyright.txt for details.
30 #
31 # This software is distributed WITHOUT ANY WARRANTY; without even the
32 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
33 # See the License for more information.
34 #=============================================================================
35 # (To distribute this file outside of CMake, substitute the full
36 #  License text for the above reference.)
37
38 # Look for 'git' or 'eg' (easy git)
39 #
40 set(git_names git eg)
41
42 # Prefer .cmd variants on Windows unless running in a Makefile
43 # in the MSYS shell.
44 #
45 if(WIN32)
46   if(NOT CMAKE_GENERATOR MATCHES "MSYS")
47     set(git_names git.cmd git eg.cmd eg)
48   endif()
49 endif()
50
51 find_program(GIT_EXECUTABLE
52   NAMES ${git_names}
53   PATH_SUFFIXES Git/cmd Git/bin
54   DOC "git command line client"
55   )
56 mark_as_advanced(GIT_EXECUTABLE)
57
58 if(GIT_EXECUTABLE)
59   execute_process(COMMAND ${GIT_EXECUTABLE} --version
60                   OUTPUT_VARIABLE git_version
61                   ERROR_QUIET
62                   OUTPUT_STRIP_TRAILING_WHITESPACE)
63   if (git_version MATCHES "^git version [0-9]")
64     string(REPLACE "git version " "" GIT_VERSION_STRING "${git_version}")
65   endif()
66   unset(git_version)
67 endif()
68
69 # Handle the QUIETLY and REQUIRED arguments and set GIT_FOUND to TRUE if
70 # all listed variables are TRUE
71
72 include(FindPackageHandleStandardArgs)
73 find_package_handle_standard_args(Git GIT_EXECUTABLE
74                                       GIT_VERSION_STRING)