1 # The module defines the following variables:
2 # GIT_EXECUTABLE - path to git command line client
3 # GIT_FOUND - true if the command line client was found
4 # GIT_VERSION_STRING - the version of git found (since CMake 2.8.8)
8 # message("git found: ${GIT_EXECUTABLE}")
11 #=============================================================================
12 # Copyright 2010 Kitware, Inc.
13 # Copyright 2012 Rolf Eike Beer <eike@sf-mail.de>
15 # Distributed under the OSI-approved BSD License (the "License");
16 # see accompanying file Copyright.txt for details.
18 # This software is distributed WITHOUT ANY WARRANTY; without even the
19 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20 # See the License for more information.
21 #=============================================================================
22 # (To distribute this file outside of CMake, substitute the full
23 # License text for the above reference.)
25 # Look for 'git' or 'eg' (easy git)
29 # Prefer .cmd variants on Windows unless running in a Makefile
33 if(NOT CMAKE_GENERATOR MATCHES "MSYS")
34 set(git_names git.cmd git eg.cmd eg)
38 find_program(GIT_EXECUTABLE
40 PATH_SUFFIXES Git/cmd Git/bin
41 DOC "git command line client"
43 mark_as_advanced(GIT_EXECUTABLE)
46 execute_process(COMMAND ${GIT_EXECUTABLE} --version
47 OUTPUT_VARIABLE git_version
49 OUTPUT_STRIP_TRAILING_WHITESPACE)
50 if (git_version MATCHES "^git version [0-9]")
51 string(REPLACE "git version " "" GIT_VERSION_STRING "${git_version}")
56 # Handle the QUIETLY and REQUIRED arguments and set GIT_FOUND to TRUE if
57 # all listed variables are TRUE
59 include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
60 find_package_handle_standard_args(Git
61 REQUIRED_VARS GIT_EXECUTABLE
62 VERSION_VAR GIT_VERSION_STRING)