Skip to content

Commit

Permalink
[cmake] split mp version into semver and build version
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei-toterman committed Dec 4, 2024
1 parent 1b49ef6 commit 88b06af
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 88b06af

Please sign in to comment.