git version handler more robust now

This commit is contained in:
Robin Müller 2022-04-22 14:47:28 +02:00
parent 513ae9dc10
commit 9c7eba4431
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814

View File

@ -1,5 +1,9 @@
cmake_minimum_required(VERSION 3.13) cmake_minimum_required(VERSION 3.13)
set(FSFW_VERSION_IF_GIT_FAILS 4)
set(FSFW_SUBVERSION_IF_GIT_FAILS 0)
set(FSFW_REVISION_IF_GIT_FAILS 0)
# Add the cmake folder so the FindSphinx module is found # Add the cmake folder so the FindSphinx module is found
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ) list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" )
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake-modules") list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake-modules")
@ -44,21 +48,27 @@ project(${LIB_FSFW_NAME})
add_library(${LIB_FSFW_NAME}) add_library(${LIB_FSFW_NAME})
# Version handling # Version handling
if(EXISTS .git)
include(helpers) include(helpers)
determine_version_with_git() determine_version_with_git("--exclude" "docker_*")
set(FSFW_GIT_INFO ${GIT_INFO} CACHE STRING "Version information retrieved with git describe") set(FSFW_GIT_INFO ${GIT_INFO} CACHE STRING "Version information retrieved with git describe")
list(GET FSFW_GIT_INFO 1 FSFW_VERSION) list(GET FSFW_GIT_INFO 1 FSFW_VERSION)
list(GET FSFW_GIT_INFO 2 FSFW_SUBVERSION) list(GET FSFW_GIT_INFO 2 FSFW_SUBVERSION)
list(GET FSFW_GIT_INFO 3 FSFW_REVISION) list(GET FSFW_GIT_INFO 3 FSFW_REVISION)
list(GET FSFW_GIT_INFO 4 FSFW_VERSION_CST_GIT_SHA1) list(GET FSFW_GIT_INFO 4 FSFW_VERSION_CST_GIT_SHA1)
if(NOT FSFW_VERSION) if(NOT FSFW_VERSION)
set(FSFW_VERSION -1) set(FSFW_VERSION ${FSFW_VERSION_IF_GIT_FAILS})
endif() endif()
if(NOT FSFW_SUBVERSION) if(NOT FSFW_SUBVERSION)
set(FSFW_SUBVERSION -1) set(FSFW_SUBVERSION ${FSFW_SUBVERSION_IF_GIT_FAILS})
endif() endif()
if(NOT FSFW_REVISION) if(NOT FSFW_REVISION)
set(FSFW_REVISION -1) set(FSFW_REVISION ${FSFW_REVISION_IF_GIT_FAILS})
endif()
else()
set(FSFW_VERSION ${FSFW_VERSION_IF_GIT_FAILS})
set(FSFW_SUBVERSION ${FSFW_SUBVERSION_IF_GIT_FAILS})
set(FSFW_REVISION ${FSFW_REVISION_IF_GIT_FAILS})
endif() endif()
if(FSFW_BUILD_UNITTESTS) if(FSFW_BUILD_UNITTESTS)