From bd5067d49cc113750887b62f865df8048c648cce Mon Sep 17 00:00:00 2001 From: Mathias Preiner Date: Wed, 19 Sep 2018 08:24:11 -0700 Subject: [PATCH] cmake: Guard GetGitRevisionDescription. --- src/base/CMakeLists.txt | 24 ++++++++++++++++-------- src/base/git_versioninfo.cpp.in | 2 +- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/base/CMakeLists.txt b/src/base/CMakeLists.txt index 9ef564df8..d190ec199 100644 --- a/src/base/CMakeLists.txt +++ b/src/base/CMakeLists.txt @@ -3,17 +3,25 @@ include(GetGitRevisionDescription) get_git_head_revision(GIT_REFSPEC GIT_SHA1) -git_local_changes(GIT_IS_DIRTY) -if(${GIT_IS_DIRTY} STREQUAL "DIRTY") - set(GIT_IS_DIRTY "true") + +if(GIT_SHA1) + git_local_changes(GIT_IS_DIRTY) + set(GIT_BUILD "true") + if(${GIT_IS_DIRTY} STREQUAL "DIRTY") + set(GIT_IS_DIRTY "true") + else() + set(GIT_IS_DIRTY "false") + endif() + execute_process( + COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD + OUTPUT_VARIABLE GIT_BRANCH + OUTPUT_STRIP_TRAILING_WHITESPACE + ) else() + set(GIT_BUILD "false") set(GIT_IS_DIRTY "false") + set(GIT_SHA1 "") endif() -execute_process( - COMMAND "${GIT_EXECUTABLE}" rev-parse --abbrev-ref HEAD - OUTPUT_VARIABLE GIT_BRANCH - OUTPUT_STRIP_TRAILING_WHITESPACE -) #-----------------------------------------------------------------------------# # Generate git_versioninfo.cpp diff --git a/src/base/git_versioninfo.cpp.in b/src/base/git_versioninfo.cpp.in index e601a851a..20da094bc 100644 --- a/src/base/git_versioninfo.cpp.in +++ b/src/base/git_versioninfo.cpp.in @@ -1,5 +1,5 @@ #include "base/configuration.h" -const bool ::CVC4::Configuration::IS_GIT_BUILD = true; +const bool ::CVC4::Configuration::IS_GIT_BUILD = @GIT_BUILD@; const char* const ::CVC4::Configuration::GIT_BRANCH_NAME = "@GIT_BRANCH@"; const char* const ::CVC4::Configuration::GIT_COMMIT = "@GIT_SHA1@"; const bool ::CVC4::Configuration::GIT_HAS_MODIFICATIONS = @GIT_IS_DIRTY@; -- 2.30.2