-
Notifications
You must be signed in to change notification settings - Fork 8
/
octf-version.cmake
48 lines (43 loc) · 1.3 KB
/
octf-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
48
set(OCTF_VERSION_MAIN 22)
set(OCTF_VERSION_MAJOR 6)
set(OCTF_VERSION_MINOR 0)
set(OCTF_VERSION "${OCTF_VERSION_MAIN}.${OCTF_VERSION_MAJOR}.${OCTF_VERSION_MINOR}")
execute_process(
COMMAND git log --pretty=format:%h -n 1
OUTPUT_VARIABLE OCTF_VERSION_LABEL
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
ERROR_QUIET
)
message(STATUS "OCTF VERSION: ${OCTF_VERSION}")
if (NOT OCTF_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 OCTF_VERSION_LABEL
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
ERROR_QUIET
)
endif()
if (OCTF_VERSION_LABEL)
message(STATUS "OCTF LABEL: ${OCTF_VERSION_LABEL}")
endif()
# Generate version file
file(
WRITE ${CMAKE_CURRENT_BINARY_DIR}/VERSION
"OCTF_VERSION_MAIN=${OCTF_VERSION_MAIN}\n"
)
file(
APPEND ${CMAKE_CURRENT_BINARY_DIR}/VERSION
"OCTF_VERSION_MAJOR=${OCTF_VERSION_MAJOR}\n"
)
file(
APPEND ${CMAKE_CURRENT_BINARY_DIR}/VERSION
"OCTF_VERSION_MINOR=${OCTF_VERSION_MINOR}\n"
)
if (OCTF_VERSION_LABEL)
file(
APPEND ${CMAKE_CURRENT_BINARY_DIR}/VERSION
"OCTF_VERSION_LABEL=${OCTF_VERSION_LABEL}\n"
)
endif()