-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGenerateVersion.cmake
33 lines (29 loc) · 1.06 KB
/
GenerateVersion.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
find_package(Git)
if (GIT_EXECUTABLE)
execute_process(
COMMAND ${GIT_EXECUTABLE} status --porcelain
OUTPUT_VARIABLE DIRTY_STRINGS
)
if (NOT DIRTY_STRINGS STREQUAL "")
string(TIMESTAMP date "%Y-%m-%d %H:%M")
execute_process(
COMMAND ${GIT_EXECUTABLE} log -1 --format=%h-dirty
OUTPUT_VARIABLE WAMPY_VERSION
RESULT_VARIABLE ERROR_CODE
OUTPUT_STRIP_TRAILING_WHITESPACE
)
string(CONCAT WAMPY_VERSION ${WAMPY_VERSION} ", " ${date})
else ()
execute_process(
COMMAND ${GIT_EXECUTABLE} log -1 "--format=%h, %ad" "--date=format:%Y-%m-%d %H:%M"
OUTPUT_VARIABLE WAMPY_VERSION
RESULT_VARIABLE ERROR_CODE
OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif ()
endif ()
if (WAMPY_VERSION STREQUAL "")
set(WAMPY_VERSION unknown)
message(WARNING "Failed to determine version from Git tags. Using default version \"${WAMPY_VERSION}\".")
endif ()
configure_file(${SRC} ${DST} @ONLY)