-
Notifications
You must be signed in to change notification settings - Fork 214
/
FindMsysGit.cmake
40 lines (36 loc) · 1.44 KB
/
FindMsysGit.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# The module defines the following variables:
# MSYSGIT_BIN_DIR - path to the tool binaries
# MSYSGIT_FOUND - true if the command line client was found
# Example usage:
# find_package(MsysGit)
# if(MSYSGIT_FOUND)
# message("msysGit tools found in: ${MSYSGIT_BIN_DIR}")
# endif()
if(GIT_EXECUTABLE)
execute_process(COMMAND ${GIT_EXECUTABLE} --version
OUTPUT_VARIABLE git_version
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
if (git_version MATCHES "^git version [0-9]")
string(REPLACE "git version " "" GIT_VERSION_STRING "${git_version}")
if (git_version MATCHES "msysgit")
set(GIT_IS_MSYSGIT TRUE)
else()
set(GIT_IS_MSYSGIT FALSE)
endif()
endif()
unset(git_version)
endif()
if(GIT_IS_MSYSGIT)
get_filename_component(MSYS_DIR ${GIT_EXECUTABLE} PATH)
find_path(MSYSGIT_BIN_DIR
NAMES date.exe grep.exe unzip.exe git.exe PATHS ${MSYS_DIR}/../bin NO_DEFAULT_PATH)
else()
find_path(MSYSGIT_BIN_DIR
NAMES date.exe grep.exe unzip.exe git.exe PATH_SUFFIXES Git/bin)
endif()
# Handle the QUIETLY and REQUIRED arguments and set MSYSGIT_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(MsysGit
REQUIRED_VARS MSYSGIT_BIN_DIR)