From 586e5e7b9b4e4bcfd932ef43fe45278371e3e14a Mon Sep 17 00:00:00 2001 From: Peter M. Groen Date: Thu, 21 Apr 2022 15:06:42 +0200 Subject: [PATCH] Fix for branch not having a tag.. --- projectheader.cmake | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/projectheader.cmake b/projectheader.cmake index 750268c..d3d0340 100644 --- a/projectheader.cmake +++ b/projectheader.cmake @@ -12,7 +12,16 @@ if(GIT_FOUND) execute_process(COMMAND ${GIT_EXECUTABLE} describe --abbrev=0 --tags WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} OUTPUT_VARIABLE CURRENT_PROJECT_VERSION - OUTPUT_STRIP_TRAILING_WHITESPACE) + OUTPUT_STRIP_TRAILING_WHITESPACE + RESULT_VARIABLE GIT_SUBMOD_RESULT) + + # Exit code will be 128 if no tags are present + if( ${GIT_SUBMOD_RESULT} EQUAL 128 ) + set(CURRENT_PROJECT_VERSION "0.0.1") + endif() + + + message( STATUS "================================================================" ) message( STATUS "Found the following tag : ${CURRENT_PROJECT_VERSION}") message( STATUS "================================================================" ) @@ -25,6 +34,7 @@ else() message( FATAL "Unable to determine the version of the software.") endif() + message( STATUS "" ) message( STATUS "================================================================" ) message( STATUS "Creating Makefile of ${CURRENT_PROJECT_NAME}" ) -- libgit2 0.21.4