diff --git a/CMakeLists.txt b/CMakeLists.txt index b3ab390d62..dbeed86903 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -137,7 +137,7 @@ find_package(Qt6 COMPONENTS Core Concurrent Network REQUIRED) # POCO config find_package(Poco REQUIRED COMPONENTS Foundation Zip) -function(determine_version OUTPUT_VARIABLE) +function(determine_version OUTPUT_VARIABLE SEMANTIC_VERSION BUILD_VERSION) # use upstream repo as the authoritative reference when checking for release status # set -DMULTIPASS_UPSTREAM="" to use the local repository if(MULTIPASS_UPSTREAM) @@ -208,14 +208,33 @@ function(determine_version OUTPUT_VARIABLE) if(VERSION_MATCH) set(${OUTPUT_VARIABLE} ${CMAKE_MATCH_1} PARENT_SCOPE) + set(VERSION_STRING ${CMAKE_MATCH_1}) + else() message(FATAL_ERROR "Invalid tag detected: ${NEW_VERSION}") endif() + + string(REPLACE "-" ";" MULTIPASS_VERSION_COMPONENTS ${VERSION_STRING}) + list(GET MULTIPASS_VERSION_COMPONENTS 0 MULTIPASS_SEMANTIC_VERSION) + set(MULTIPASS_SEMANTIC_VERSION ${MULTIPASS_SEMANTIC_VERSION}) + set(MULTIPASS_BUILD_VERSION 0) + list(LENGTH MULTIPASS_VERSION_COMPONENTS MULTIPASS_VERSION_COMPONENTS_LENGTH) + if (MULTIPASS_VERSION_COMPONENTS_LENGTH GREATER 1) + list(GET MULTIPASS_VERSION_COMPONENTS 1 MULTIPASS_BUILD_VERSION_STR) + string(REGEX REPLACE "[^0-9]" "" MULTIPASS_BUILD_VERSION_NUMBER "${MULTIPASS_BUILD_VERSION_STR}") + if(NOT "${MULTIPASS_BUILD_VERSION_NUMBER}" STREQUAL "") + set(MULTIPASS_BUILD_VERSION "${MULTIPASS_BUILD_VERSION_NUMBER}") + endif() + endif() + set(MULTIPASS_SEMANTIC_VERSION ${MULTIPASS_SEMANTIC_VERSION} PARENT_SCOPE) + set(MULTIPASS_BUILD_VERSION ${MULTIPASS_BUILD_VERSION} PARENT_SCOPE) endfunction() -determine_version(MULTIPASS_VERSION) +determine_version(MULTIPASS_VERSION MULTIPASS_SEMANTIC_VERSION MULTIPASS_BUILD_VERSION) set(MULTIPASS_VERSION ${MULTIPASS_VERSION}) message(STATUS "Setting version to: ${MULTIPASS_VERSION}") +message(STATUS "Setting semantic version to: ${MULTIPASS_SEMANTIC_VERSION}") +message(STATUS "Setting build version to: ${MULTIPASS_BUILD_VERSION}") set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED TRUE)