From 5980182db04e4efc6c110e8ae142fe00540e9619 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kjell=20Hedstr=C3=B6m=20-=20seeking=20Senior=20Engineering?= =?UTF-8?q?=20roles=20as=20well=20as=20contract=20opportunities?= Date: Wed, 6 Dec 2023 20:14:22 -0700 Subject: [PATCH] Versioning (#515) * making sure that git checkout of tags, doesn't get incrementing numbers when master gets more commits --- CMakeLists.txt | 11 +++++------ CPackLists.txt | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 83ded10..ac78173 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,28 +68,27 @@ endif() # Calculate the version number SET(MAJOR_VERSION 2) -SET(MINOR_VERSION 3) +SET(MINOR_VERSION 4) IF ( NOT VERSION ) IF ( "${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows" ) message("windows: Extracting git software version") - execute_process(COMMAND cmd /c "git rev-list --branches HEAD | find /v " " /c" OUTPUT_VARIABLE GIT_VERSION WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) + execute_process(COMMAND cmd /c "git rev-list ${MAJOR_VERSION}.${MINOR_VERSION}..HEAD | find /v " " /c" OUTPUT_VARIABLE GIT_RELEASE_COMMITS WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) ELSE() IF(UNIX OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin") message( STATUS "nix: Extracting git software version" ) ELSE() message( STATUS "unknown platform: extracting git software version" ) ENDIF() - execute_process(COMMAND bash "-c" "git rev-list --branches HEAD | wc -l | tr -d ' ' | tr -d '\n'" OUTPUT_VARIABLE GIT_VERSION WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) + execute_process(COMMAND bash "-c" "git rev-list ${MAJOR_VERSION}.${MINOR_VERSION}..HEAD | wc -l" OUTPUT_VARIABLE GIT_RELEASE_COMMITS WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) ENDIF() - math(EXPR VERSION-BASE ${GIT_VERSION}/255) - math(EXPR VERSION-REMAINDER ${GIT_VERSION}%255) + string(STRIP ${GIT_RELEASE_COMMITS} GIT_RELEASE_COMMITS) message( STATUS "git build version: ${GIT_VERSION}" ) message( STATUS "version base: ${VERSION-BASE}" ) message( STATUS "version remainder: ${VERSION-REMAINDER}" ) SET(BUILD_NUMBER ${VERSION-BASE}) - SET(VERSION ${MAJOR_VERSION}.${MINOR_VERSION}.${BUILD_NUMBER}-${VERSION-REMAINDER}) + SET(VERSION ${MAJOR_VERSION}.${MINOR_VERSION}-${GIT_RELEASE_COMMITS}) #-${VERSION-REMAINDER}) ENDIF() message( STATUS "Software Version: ${VERSION}" ) diff --git a/CPackLists.txt b/CPackLists.txt index 4ba614d..c35c243 100644 --- a/CPackLists.txt +++ b/CPackLists.txt @@ -24,7 +24,7 @@ INCLUDE(GNUInstallDirs) SET(CPACK_PACKAGE_NAME g3log) SET(CPACK_PACKAGE_VERSION_MAJOR ${MAJOR_VERSION}) SET(CPACK_PACKAGE_VERSION_MINOR ${MINOR_VERSION}) -SET(CPACK_PACKAGE_VERSION_PATCH ${BUILD_NUMBER}) +SET(CPACK_PACKAGE_VERSION_PATCH ${GIT_RELEASE_COMMITS}) SET(CPACK_PACKAGE_DESCRIPTION "Asynchronous 'crash safe' logger License: http://unlicense.org Repository: https://github.com/KjellKod/g3log")