-
Notifications
You must be signed in to change notification settings - Fork 28
/
Version.cmake
21 lines (21 loc) · 1.14 KB
/
Version.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
set( MAJOR_VERSION 2)
SET(MINOR_VERSION 2)
if (${VERSION}.x STREQUAL ".x")
if (MSVC)
message("windows: Extracting git software version")
execute_process(COMMAND powershell "(git rev-list --branches HEAD | Measure-Object -line).Lines" OUTPUT_VARIABLE GIT_VERSION WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
else()
if(UNIX OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
message("nix: Extracting git software version")
else()
message("unknown platform: extracting git software version")
endif()
execute_process(COMMAND bash "-c" "git rev-list --branches HEAD | wc -l | tr -d ' ' | tr -d '\n'" OUTPUT_VARIABLE GIT_VERSION WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
endif()
MESSAGE("VERSION SO FAR ${GIT_VERSION}")
math(EXPR VERSION-BASE ${GIT_VERSION}/255) # TODO the math lines can just be commented out when debugging in VSCode.
math(EXPR VERSION-REMAINDER ${GIT_VERSION}%255) # as the GIT_VERSION can not easily be retrieved in VS
SET(BUILD_NUMBER ${VERSION-BASE})
SET(VERSION ${MAJOR_VERSION}.${MINOR_VERSION}.${BUILD_NUMBER}-${VERSION-REMAINDER})
endif()
message("Software Version: ${VERSION}")