From 12c894aa94a727ecd0c78be572d4e76345873c72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kjell=20Hedstr=C3=B6m?= <331742+KjellKod@users.noreply.github.com> Date: Wed, 6 Dec 2023 19:16:12 -0700 Subject: [PATCH 1/4] in progress --- CMakeLists.txt | 20 +++++++++----------- CPackLists.txt | 2 +- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 83ded10f..4538f0f3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,29 +69,27 @@ endif() # Calculate the version number SET(MAJOR_VERSION 2) SET(MINOR_VERSION 3) +# patch will be number of commits since this ^ tag. +# HOW TO UPDATE NEXT VERSION NUMBER +# 1. set the values above for major, and minor. +# 2. The last number, the patch number will be number of commits since the last tag. 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 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 | tr -d ' '" OUTPUT_VARIABLE COMMITS WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) ENDIF() - - math(EXPR VERSION-BASE ${GIT_VERSION}/255) - math(EXPR VERSION-REMAINDER ${GIT_VERSION}%255) - 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}.${COMMITS}) ENDIF() -message( STATUS "Software Version: ${VERSION}" ) +message( STATUS "[Build.cmake --> Software Version: ${VERSION}]" ) +message( STATUS "[MAJOR_VERSION: ${MAJOR_VERSION}. MINOR_VERSION: ${MINOR_VERSION}, BUILD_COMMITS: ${COMMITS}]" ) # ============================================================================ # G3LOG OPTIONAL FEATURES diff --git a/CPackLists.txt b/CPackLists.txt index 4ba614d2..eaa3f7ef 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 ${COMMITS}) SET(CPACK_PACKAGE_DESCRIPTION "Asynchronous 'crash safe' logger License: http://unlicense.org Repository: https://github.com/KjellKod/g3log") From fe299374c87eb0b657f2ccc3b2a688906adf6131 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kjell=20Hedstr=C3=B6m?= <331742+KjellKod@users.noreply.github.com> Date: Wed, 6 Dec 2023 19:43:31 -0700 Subject: [PATCH 2/4] making sure that git checkout of tags, doesn't get incrementing numbers when master gets more commits --- CMakeLists.txt | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4538f0f3..f324ee1b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,28 +68,28 @@ endif() # Calculate the version number SET(MAJOR_VERSION 2) -SET(MINOR_VERSION 3) -# patch will be number of commits since this ^ tag. +SET(MINOR_VERSION 4) -# HOW TO UPDATE NEXT VERSION NUMBER -# 1. set the values above for major, and minor. -# 2. The last number, the patch number will be number of commits since the last tag. IF ( NOT VERSION ) IF ( "${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows" ) message("windows: Extracting git software version") - execute_process(COMMAND cmd /c "git rev-list ${MAJOR_VERSION}.${MINOR_VERSION}..HEAD | find /v " " /c" OUTPUT_VARIABLE COMMITS 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 ${MAJOR_VERSION}.${MINOR_VERSION}..HEAD | wc -l | tr -d ' '" OUTPUT_VARIABLE COMMITS WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) + execute_process(COMMAND bash "-c" "git rev-list ${MAJOR_VERSION}.${MINOR_VERSION}..HEAD | wc -l | tr -d ' ' | tr -d '\n'" OUTPUT_VARIABLE GIT_RELEASE_COMMITS WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) ENDIF() - SET(VERSION ${MAJOR_VERSION}.${MINOR_VERSION}.${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}-${GIT_RELEASE_COMMITS}) #-${VERSION-REMAINDER}) ENDIF() -message( STATUS "[Build.cmake --> Software Version: ${VERSION}]" ) -message( STATUS "[MAJOR_VERSION: ${MAJOR_VERSION}. MINOR_VERSION: ${MINOR_VERSION}, BUILD_COMMITS: ${COMMITS}]" ) +message( STATUS "Software Version: ${VERSION}" ) # ============================================================================ # G3LOG OPTIONAL FEATURES From fe766d707c58995d09c343f6e8573db27a9f149d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kjell=20Hedstr=C3=B6m?= <331742+KjellKod@users.noreply.github.com> Date: Wed, 6 Dec 2023 19:46:07 -0700 Subject: [PATCH 3/4] updated cpack --- CPackLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CPackLists.txt b/CPackLists.txt index eaa3f7ef..c35c2437 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 ${COMMITS}) +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") From 589ff8bced25aa36e85ecf7107ce20ce2f63fbdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kjell=20Hedstr=C3=B6m?= <331742+KjellKod@users.noreply.github.com> Date: Wed, 6 Dec 2023 20:03:59 -0700 Subject: [PATCH 4/4] simplified whitespace trailing or not removal --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f324ee1b..ac781731 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -80,9 +80,10 @@ IF ( NOT VERSION ) ELSE() message( STATUS "unknown platform: extracting git software version" ) ENDIF() - execute_process(COMMAND bash "-c" "git rev-list ${MAJOR_VERSION}.${MINOR_VERSION}..HEAD | wc -l | tr -d ' ' | tr -d '\n'" OUTPUT_VARIABLE GIT_RELEASE_COMMITS 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() + 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}" )