WSL/SLF GitLab Repository

Commit 72f59647 authored by Mathias Bavay's avatar Mathias Bavay
Browse files

Ported the BuildVersion.cmake from MeteoIO

parent 9ed923e5
#SPDX-License-Identifier: LGPL-3.0-or-later
#building version number in variable _versionString
MACRO (GETDATE TODAY)
......@@ -19,8 +20,14 @@ MACRO (GETDATE TODAY)
ENDIF(CMAKE_VERSION VERSION_GREATER 2.8.11)
ENDMACRO (GETDATE)
MACRO (GET_TORTOISE_GIT_WCREV PROJECT_GIT_STR)
IF("${PROJECT_GIT_STR}" MATCHES "HEAD is ([a-zA-Z0-9]+)")
STRING(SUBSTRING "${CMAKE_MATCH_1}" 0 7 GIT_VERSION)
ENDIF()
ENDMACRO (GET_TORTOISE_GIT_WCREV)
MACRO(BuildVersionSVN)
FIND_PACKAGE(Subversion)
FIND_PACKAGE(Subversion QUIET)
IF(Subversion_FOUND)
SET(VERSION_FROM_SVN OFF CACHE BOOL "Retrieve software version from Subversion")
IF(VERSION_FROM_SVN)
......@@ -36,8 +43,9 @@ MACRO(BuildVersionSVN)
ENDMACRO(BuildVersionSVN)
MACRO(BuildVersionGIT)
FIND_PACKAGE(Git)
FIND_PACKAGE(Git QUIET)
IF(GIT_FOUND)
MARK_AS_ADVANCED(GIT_EXECUTABLE)
SET(VERSION_FROM_GIT OFF CACHE BOOL "Retrieve software version from Git")
IF(VERSION_FROM_GIT)
execute_process(
......@@ -49,10 +57,28 @@ MACRO(BuildVersionGIT)
)
GETDATE(TODAY)
SET(_versionString "${TODAY}.${project_WC_REVISION}")
ELSE(VERSION_FROM_GIT)
SET(_versionString "${VERSION_MAJOR}.${VERSION_MINOR}${VERSION_PATCH}")
ENDIF(VERSION_FROM_GIT)
ELSE(GIT_FOUND)
SET(_versionString "${VERSION_MAJOR}.${VERSION_MINOR}${VERSION_PATCH}")
find_program(TORTOISE_WCREV gitWCRev HINTS $ENV{PATH} QUIET)
if(TORTOISE_WCREV)
MARK_AS_ADVANCED(TORTOISE_WCREV)
SET(VERSION_FROM_GIT OFF CACHE BOOL "Retrieve software version from Git")
IF(VERSION_FROM_GIT)
execute_process(
COMMAND ${TORTOISE_WCREV} "${PROJECT_SOURCE_DIR}"
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
OUTPUT_VARIABLE project_WC_REVISION
ERROR_QUIET
)
string(REPLACE "\\" "/" project_WC_REVISION "${project_WC_REVISION}")
GET_TORTOISE_GIT_WCREV(${project_WC_REVISION})
GETDATE(TODAY)
SET(_versionString "${TODAY}.${GIT_VERSION}")
ENDIF(VERSION_FROM_GIT)
ENDIF(TORTOISE_WCREV)
ENDIF(GIT_FOUND)
IF(NOT _versionString)
SET(_versionString "${VERSION_MAJOR}.${VERSION_MINOR}${VERSION_PATCH}")
ENDIF()
ENDMACRO(BuildVersionGIT)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment