From 7108d8450bcfffd6141887bd5bd390b040f67ea6 Mon Sep 17 00:00:00 2001 From: Oliver Hamlet Date: Sat, 18 May 2024 16:55:23 +0100 Subject: [PATCH] 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. --- CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 062b382e..359921ec 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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()