cmake: Guard GetGitRevisionDescription.
authorMathias Preiner <mathias.preiner@gmail.com>
Wed, 19 Sep 2018 15:24:11 +0000 (08:24 -0700)
committerMathias Preiner <mathias.preiner@gmail.com>
Sat, 22 Sep 2018 23:30:59 +0000 (16:30 -0700)
src/base/CMakeLists.txt
src/base/git_versioninfo.cpp.in

index 9ef564df8d0539b287f2fcceea99766056ceac8e..d190ec1994290067ebbddf935dcd9a718ba3e26a 100644 (file)
@@ -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
index e601a851a6a055867536c9805b706c93c3d2f40b..20da094bc8c39ed8e3ec058c20337c109cb8f413 100644 (file)
@@ -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@;