forked from Open-CAS/standalone-linux-io-tracer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
version.cmake
47 lines (43 loc) · 1.39 KB
/
version.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
41
42
43
44
45
46
47
set(IOTRACE_VERSION_MAIN 20)
set(IOTRACE_VERSION_MAJOR 3)
set(IOTRACE_VERSION_MINOR 0)
set(IOTRACE_VERSION ${IOTRACE_VERSION_MAIN}.${IOTRACE_VERSION_MAJOR}.${IOTRACE_VERSION_MINOR})
execute_process(
COMMAND bash -c "git log --pretty=format:%h -n 1 | tr -d '\n'"
OUTPUT_VARIABLE IOTRACE_VERSION_LABEL
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
ERROR_QUIET
)
if (NOT IOTRACE_VERSION_LABEL)
message(STATUS "git repository not found, trying label from VERSION file")
execute_process(
COMMAND bash -c "grep LABEL < ${CMAKE_CURRENT_LIST_DIR}/VERSION | awk -F '=' '{print $2}' \
| tr -d '\n'"
OUTPUT_VARIABLE IOTRACE_VERSION_LABEL
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
ERROR_QUIET
)
endif()
message(STATUS "IOTRACE VERSION: ${IOTRACE_VERSION}")
if (IOTRACE_VERSION_LABEL)
message(STATUS "IOTRACE LABEL: ${IOTRACE_VERSION_LABEL}")
endif()
# Generate version file
file(
WRITE ${CMAKE_CURRENT_BINARY_DIR}/VERSION
"IOTRACE_VERSION_MAIN=${IOTRACE_VERSION_MAIN}\n"
)
file(
APPEND ${CMAKE_CURRENT_BINARY_DIR}/VERSION
"IOTRACE_VERSION_MAJOR=${IOTRACE_VERSION_MAJOR}\n"
)
file(
APPEND ${CMAKE_CURRENT_BINARY_DIR}/VERSION
"IOTRACE_VERSION_MINOR=${IOTRACE_VERSION_MINOR}\n"
)
if (IOTRACE_VERSION_LABEL)
file(
APPEND ${CMAKE_CURRENT_BINARY_DIR}/VERSION
"IOTRACE_VERSION_LABEL=${IOTRACE_VERSION_LABEL}\n"
)
endif()