1 |
zoff99 |
56 |
FIND_PROGRAM(GIT_EXECUTABLE NAMES git git.exe DOC "git command line client")
|
2 |
|
|
|
3 |
|
|
get_filename_component(SOURCE_DIR ${SRC} PATH)
|
4 |
|
|
|
5 |
|
|
if (GIT_EXECUTABLE)
|
6 |
|
|
EXECUTE_PROCESS(
|
7 |
|
|
COMMAND ${GIT_EXECUTABLE} log "--format=%h %d"
|
8 |
|
|
WORKING_DIRECTORY "${SOURCE_DIR}"
|
9 |
|
|
OUTPUT_VARIABLE VERSION
|
10 |
|
|
ERROR_VARIABLE GIT_ERROR
|
11 |
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
12 |
|
|
ERROR_STRIP_TRAILING_WHITESPACE
|
13 |
|
|
)
|
14 |
|
|
if(NOT VERSION)
|
15 |
|
|
message(STATUS "Cannot determine current git commit - git error: '${GIT_ERROR}'")
|
16 |
|
|
set(VERSION "0000")
|
17 |
|
|
endif()
|
18 |
|
|
else()
|
19 |
|
|
message(STATUS "git not found, cannot record git commit")
|
20 |
|
|
set(VERSION "0000")
|
21 |
|
|
endif(GIT_EXECUTABLE)
|
22 |
|
|
|
23 |
|
|
string(REGEX MATCH "R[0-9]+" VERSION_NUM ${VERSION} )
|
24 |
|
|
if(NOT VERSION_NUM)
|
25 |
|
|
message(STATUS "I can't find a release tag. This is probably not Navit's official tree")
|
26 |
|
|
message(STATUS "It's OK, I will default to 0000")
|
27 |
|
|
set(VERSION_NUM "0000")
|
28 |
|
|
endif()
|
29 |
|
|
string(REPLACE "R" "" VERSION_NUM ${VERSION_NUM} )
|
30 |
|
|
if(NOT VERSION_NUM)
|
31 |
|
|
set(VERSION_NUM "0000")
|
32 |
|
|
endif()
|
33 |
|
|
|
34 |
|
|
string(REGEX MATCH "^[a-z0-9]+" VERSION ${VERSION} )
|
35 |
|
|
|
36 |
|
|
if (STRIP_M)
|
37 |
|
|
set(VERSION ${VERSION_NUM})
|
38 |
|
|
endif()
|
39 |
|
|
|
40 |
|
|
set(NAVIT_VARIANT "-")
|
41 |
|
|
|
42 |
|
|
set(${NAME} ${VERSION})
|
43 |
|
|
|
44 |
|
|
message (STATUS "Git commit: ${${NAME}}")
|
45 |
|
|
CONFIGURE_FILE(${SRC} ${DST} @ONLY)
|