Improve handling of build not in a Git repository

If Git is installed but the build is not running in a Git repository, then git rev-parse will fail and GIT_COMMIT_STRING will be empty.
This commit is contained in:
Oliver Hamlet
2024-05-18 16:55:23 +01:00
parent d2aa978561
commit 7108d8450b
+3 -1
View File
@@ -28,7 +28,9 @@ if(GIT_FOUND)
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT_STRING
OUTPUT_STRIP_TRAILING_WHITESPACE)
else()
endif()
if(NOT GIT_COMMIT_STRING)
set(GIT_COMMIT_STRING "unknown")
endif()