From b8896742f80cae0d7f41519132e3186c7088331c Mon Sep 17 00:00:00 2001 From: Emily Mabrey Date: Mon, 27 Sep 2021 01:03:56 -0400 Subject: [PATCH] Fix `GIT_DESCRIBE` generation Initially attempt to find tags excluding "Audacity-" and "DarkAudacity-" Allow graceful fallback case for "Audacity-" tags Add logic to remove "DarkAudacity-" tag prefix to match "Audacity-" tag behavior Signed-off-by: Emily Mabrey --- CMakeLists.txt | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8ea797684..b04e2deca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,19 +68,31 @@ set( TENACITY_MODLEVEL 0 ) # Additional version detail set( GIT_DESCRIBE "unknown" ) if( GIT_FOUND ) + # Attempt to first get "Tenacity-" tags execute_process( - COMMAND ${GIT_EXECUTABLE} describe --tags --abbrev=7 + COMMAND ${GIT_EXECUTABLE} describe --tags --abbrev=7 --exclude="Audacity-*" --exclude="DarkAudacity-*" WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE GIT_DESCRIBE OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET ) - if( GIT_DESCRIBE ) + if( DEFINED GIT_DESCRIBE AND GIT_DESCRIBE STREQUAL "" ) + # Retry, this time accepting "Audacity-" tags + execute_process( + COMMAND ${GIT_EXECUTABLE} describe --tags --abbrev=7 --exclude="DarkAudacity-*" + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE GIT_DESCRIBE + OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET + ) + endif() + + if( DEFINED GIT_DESCRIBE AND NOT GIT_DESCRIBE STREQUAL "" ) + # Copy to new variable for string manipulation set( git_output ${GIT_DESCRIBE} ) - # TODO: Remove this after first Tenacity release string( REPLACE "Audacity-" "" git_output "${git_output}" ) + string( REPLACE "DarkAudacity-" "" git_output "${git_output}" ) string( REGEX REPLACE "-.*" "" git_output "${git_output}" ) string( REPLACE "." ";" git_output "${git_output}" )