made version handling more robust
Some checks failed
EIVE/eive-obsw/pipeline/head There was a failure building this commit

This commit is contained in:
Robin Müller 2022-04-22 15:47:47 +02:00
parent 0f80501467
commit 0638c87f62
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814

View File

@ -10,6 +10,9 @@
cmake_minimum_required(VERSION 3.13) cmake_minimum_required(VERSION 3.13)
# set(CMAKE_VERBOSE TRUE) # set(CMAKE_VERBOSE TRUE)
set(OBSW_VERSION_MAJOR_IF_GIT_FAILS 0)
set(OBSW_VERSION_MINOR_IF_GIT_FAILS 0)
set(OBSW_VERSION_REVISION_IF_GIT_FAILS 0)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
@ -44,20 +47,34 @@ include(EiveHelpers)
pre_project_config() pre_project_config()
# Version handling # Version handling
set(GIT_VER_HANDLING_OK FALSE)
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git)
determine_version_with_git("--exclude" "docker_*") determine_version_with_git("--exclude" "docker_*")
set(GIT_INFO ${GIT_INFO} CACHE STRING "Version information retrieved with git describe")
if(GIT_INFO)
set(GIT_INFO ${GIT_INFO} CACHE STRING "Version information retrieved with git describe") set(GIT_INFO ${GIT_INFO} CACHE STRING "Version information retrieved with git describe")
list(GET GIT_INFO 1 OBSW_VERSION_MAJOR) list(GET GIT_INFO 1 OBSW_VERSION_MAJOR)
list(GET GIT_INFO 2 OBSW_VERSION_MINOR) list(GET GIT_INFO 2 OBSW_VERSION_MINOR)
list(GET GIT_INFO 3 OBSW_VERSION_REVISION) list(GET GIT_INFO 3 OBSW_VERSION_REVISION)
list(GET GIT_INFO 4 OBSW_VERSION_CST_GIT_SHA1) list(GET GIT_INFO 4 OBSW_VERSION_CST_GIT_SHA1)
if(NOT OBSW_VERSION_MAJOR) if(NOT OBSW_VERSION_MAJOR)
set(OBSW_VERSION_MAJOR 0) set(OBSW_VERSION_MAJOR ${OBSW_VERSION_MAJOR_IF_GIT_FAILS})
endif() endif()
if(NOT OBSW_VERSION_MINOR) if(NOT OBSW_VERSION_MINOR)
set(OBSW_VERSION_MINOR 0) set(FSFW_SUBVERSION ${OBSW_VERSION_MINOR_IF_GIT_FAILS})
endif() endif()
if(NOT OBSW_VERSION_REVISION) if(NOT OBSW_VERSION_REVISION)
set(OBSW_VERSION_REVISION 0) set(FSFW_REVISION ${OBSW_VERSION_REVISION_IF_GIT_FAILS})
endif()
set(GIT_VER_HANDLING_OK TRUE)
else()
set(GIT_VER_HANDLING_OK FALSE)
endif()
endif()
if(NOT GIT_VER_HANDLING_OK)
set(OBSW_VERSION_MAJOR ${OBSW_VERSION_MAJOR_IF_GIT_FAILS})
set(OBSW_VERSION_MINOR ${OBSW_VERSION_MINOR_IF_GIT_FAILS})
set(OBSW_VERSION_REVISION ${OBSW_VERSION_REVISION_IF_GIT_FAILS})
endif() endif()
# Check whether the user has already installed Catch2 first. This has to come before # Check whether the user has already installed Catch2 first. This has to come before