From d4f5508ee07f5e9ec0de4721c5e2a784c0c06234 Mon Sep 17 00:00:00 2001 From: Mathias Preiner Date: Tue, 12 Oct 2021 13:57:41 -0700 Subject: [PATCH] cmake: Fix git info if build directory is outside of source tree. (#7351) --- cmake/version.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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) -- 2.30.2