From: Mathias Preiner Date: Tue, 12 Oct 2021 20:57:41 +0000 (-0700) Subject: cmake: Fix git info if build directory is outside of source tree. (#7351) X-Git-Tag: cvc5-1.0.0~1075 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d4f5508ee07f5e9ec0de4721c5e2a784c0c06234;p=cvc5.git cmake: Fix git info if build directory is outside of source tree. (#7351) --- diff --git a/cmake/version.cmake b/cmake/version.cmake index 49b57ed6d..e6edd528c 100644 --- a/cmake/version.cmake +++ b/cmake/version.cmake @@ -44,7 +44,7 @@ if(GIT_FOUND) # call git describe. If result is not 0 this is not a git repository execute_process( - COMMAND ${GIT_EXECUTABLE} describe --long --tags --match cvc5-* + COMMAND ${GIT_EXECUTABLE} -C ${PROJECT_SOURCE_DIR} describe --long --tags --match cvc5-* RESULT_VARIABLE GIT_RESULT OUTPUT_VARIABLE GIT_DESCRIBE OUTPUT_STRIP_TRAILING_WHITESPACE @@ -56,7 +56,7 @@ if(GIT_FOUND) set(GIT_BUILD "true") # get current git branch execute_process( - COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD + COMMAND ${GIT_EXECUTABLE} -C ${PROJECT_SOURCE_DIR} rev-parse --abbrev-ref HEAD RESULT_VARIABLE GIT_RESULT OUTPUT_VARIABLE GIT_BRANCH OUTPUT_STRIP_TRAILING_WHITESPACE @@ -64,7 +64,7 @@ if(GIT_FOUND) # result is != 0 if worktree is dirty # note: git diff HEAD shows both staged and unstaged changes. execute_process( - COMMAND ${GIT_EXECUTABLE} diff HEAD --quiet + COMMAND ${GIT_EXECUTABLE} -C ${PROJECT_SOURCE_DIR} diff HEAD --quiet RESULT_VARIABLE GIT_RESULT ) if(GIT_RESULT EQUAL 0)