5 set(git_candidates git eg)
8 list(APPEND git_candidates eg.cmd)
10 # We don't append git.cmd, since it does not correctly return
11 # exit codes, see http://code.google.com/p/msysgit/issues/detail?id=428
12 list(APPEND git_candidates git.cmd)
16 find_program(GIT_EXECUTABLE ${git_candidates}
18 "C:/Program Files/Git/bin"
19 "C:/Program Files (x86)/Git/bin"
20 DOC
"git command line client")
21 mark_as_advanced(GIT_EXECUTABLE)
26 # check if ${dir} is a proper Git repository
27 execute_process(COMMAND ${GIT_EXECUTABLE} rev-list -n 1 HEAD
28 WORKING_DIRECTORY ${dir}
29 RESULT_VARIABLE GIT_error
40 execute_process(COMMAND ${GIT_EXECUTABLE} rev-list -n 1 HEAD
41 WORKING_DIRECTORY ${dir}
42 ERROR_VARIABLE GIT_error
43 OUTPUT_VARIABLE ${prefix}_WC_REVISION_HASH
44 OUTPUT_STRIP_TRAILING_WHITESPACE)
45 if(NOT ${GIT_error} EQUAL 0)
46 message(SEND_ERROR
"Command \"${GIT_EXECUTBALE} rev-list -n 1 HEAD\" in directory ${dir} failed with output:\n${GIT_error}")
48 execute_process(COMMAND ${GIT_EXECUTABLE} name-rev ${${prefix}_WC_REVISION_HASH}
49 WORKING_DIRECTORY ${dir}
50 OUTPUT_VARIABLE ${prefix}_WC_REVISION_NAME
51 OUTPUT_STRIP_TRAILING_WHITESPACE)
54 set(${prefix}_WC_GITSVN 0)
55 # In
case, git-svn is used, attempt to extract svn
info
56 execute_process(COMMAND ${GIT_EXECUTABLE} svn
info
57 WORKING_DIRECTORY ${dir}
58 ERROR_VARIABLE git_svn_info_error
59 OUTPUT_VARIABLE ${prefix}_WC_INFO
60 RESULT_VARIABLE git_svn_info_result
61 OUTPUT_STRIP_TRAILING_WHITESPACE)
63 if(${git_svn_info_result} EQUAL 0)
64 set(${prefix}_WC_GITSVN 1)
65 string(REGEX REPLACE
"^(.*\n)?URL: ([^\n]+).*"
66 "\\2" ${prefix}_WC_URL
"${${prefix}_WC_INFO}")
67 string(REGEX REPLACE
"^(.*\n)?Revision: ([^\n]+).*"
68 "\\2" ${prefix}_WC_REVISION
"${${prefix}_WC_INFO}")
69 string(REGEX REPLACE
"^(.*\n)?Last Changed Author: ([^\n]+).*"
70 "\\2" ${prefix}_WC_LAST_CHANGED_AUTHOR
"${${prefix}_WC_INFO}")
71 string(REGEX REPLACE
"^(.*\n)?Last Changed Rev: ([^\n]+).*"
72 "\\2" ${prefix}_WC_LAST_CHANGED_REV
"${${prefix}_WC_INFO}")
73 string(REGEX REPLACE
"^(.*\n)?Last Changed Date: ([^\n]+).*"
74 "\\2" ${prefix}_WC_LAST_CHANGED_DATE
"${${prefix}_WC_INFO}")
80 include(FindPackageHandleStandardArgs)
81 FIND_PACKAGE_HANDLE_STANDARD_ARGS(Git DEFAULT_MSG GIT_EXECUTABLE)
GIT_IS_REPO(dir, result_var)
static void info(const char *fmt,...)