-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathFindGitSvn.cmake
40 lines (33 loc) · 1.39 KB
/
FindGitSvn.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
#
#
#
MACRO(admGetGitRevision _dir _rev)
FIND_PROGRAM(GIT_EXECUTABLE git
DOC "git command line client")
MARK_AS_ADVANCED(GIT_EXECUTABLE)
IF(GIT_EXECUTABLE)
MESSAGE(STATUS "Getting git-svn version from ${_dir}")
EXECUTE_PROCESS(
COMMAND ${GIT_EXECUTABLE} rev-parse --show-toplevel ${_dir}
WORKING_DIRECTORY ${_dir}
RESULT_VARIABLE result
OUTPUT_VARIABLE topdir
)
STRING(STRIP "${topdir}" topdir)
EXECUTE_PROCESS(
COMMAND echo log --format=oneline -1 ${topdir}
COMMAND xargs ${GIT_EXECUTABLE}
COMMAND head -c 11
WORKING_DIRECTORY ${_dir}
RESULT_VARIABLE result
OUTPUT_VARIABLE output
)
STRING(STRIP "${output}" output)
STRING(SUBSTRING ${output} 0 4 output)
MESSAGE(STATUS ": ${output}")
SET( ${_rev} "${output}")
ELSE(GIT_EXECUTABLE)
SET(ADM_GIT_SVN_REVISION 0)
ENDIF(GIT_EXECUTABLE)
ENDMACRO(admGetGitRevision _dir _rev)
# FindSubversion.cmake ends here.