From 6bb10d4c8fd3ce2694b14c56973736c5eb68beea Mon Sep 17 00:00:00 2001 From: Raphael Graf Date: Wed, 4 Mar 2020 00:11:22 +0100 Subject: [PATCH] [CMAKE] Fix build outside of git repository (#440) --- CMakeLists.txt | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f6ca056b9..2dd00bb4a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -127,14 +127,19 @@ if( GIT_FOUND ) WORKING_DIRECTORY ${topdir} OUTPUT_VARIABLE - output + git_output OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET ) - - list( GET output 0 GIT_COMMIT_SHORT ) - list( GET output 1 GIT_COMMIT_LONG ) - list( GET output 2 GIT_COMMIT_TIME ) - + if ( git_output ) + list( GET git_output 0 GIT_COMMIT_SHORT ) + list( GET git_output 1 GIT_COMMIT_LONG ) + list( GET git_output 2 GIT_COMMIT_TIME ) + else() + set( GIT_COMMIT_SHORT "unknown" ) + set( GIT_COMMIT_LONG "unknown" ) + set( GIT_COMMIT_TIME "unknown" ) + endif() message( STATUS " Current Commit: ${GIT_COMMIT_SHORT}" ) message( STATUS ) endif()