From f7805727a2f1e39b024e38e0d859d9ba2ef6f2f0 Mon Sep 17 00:00:00 2001 From: klno Date: Wed, 17 Nov 2021 13:37:16 +0100 Subject: [PATCH] git_helper: use GIT_ROOT as working directory and not the -C option of git to fix usage in Windows --- cmake/git_helper.cmake | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/cmake/git_helper.cmake b/cmake/git_helper.cmake index c731852..247f2ef 100644 --- a/cmake/git_helper.cmake +++ b/cmake/git_helper.cmake @@ -1,8 +1,10 @@ # Execute git command and return the output -Function ( GitExecute COMMAND FORCE OUT_RESULT OUT_SUCCESS ) +Function ( GitExecute GIT_ROOT COMMAND FORCE OUT_RESULT OUT_SUCCESS ) Set ( ${OUT_SUCCESS} 1 PARENT_SCOPE ) Execute_Process ( COMMAND bash -c "${COMMAND}" + WORKING_DIRECTORY + "${GIT_ROOT}" RESULT_VARIABLE GIT_RET OUTPUT_VARIABLE @@ -28,17 +30,17 @@ Function ( GitGetVersion GIT_ROOT OUT_MAJOR OUT_MINOR OUT_PATCH OUT_BUILD OUT_HA EndIf ( ) # Find the latest git tag - GitExecute ( "git -C ${GIT_ROOT} describe --tags --abbrev=1 --match v[0-9].[0-9]* HEAD" False TAG SUCCESS ) + GitExecute ( "${GIT_ROOT}" "git describe --tags --abbrev=1 --match v[0-9].[0-9]* HEAD" False TAG SUCCESS ) If ( NOT ${SUCCESS} ) Return ( ) EndIf ( ) - GitExecute ( "git -C ${GIT_ROOT} status -s -uall" True DIRTY SUCCESS ) + GitExecute ( "${GIT_ROOT}" "git status -s -uall" True DIRTY SUCCESS ) If ( NOT ${SUCCESS} ) Return ( ) EndIf ( ) - GitExecute ( "git -C ${GIT_ROOT} rev-parse HEAD" True HASH SUCCESS ) + GitExecute ( "${GIT_ROOT}" "git rev-parse HEAD" True HASH SUCCESS ) If ( NOT ${SUCCESS} ) Return ( ) EndIf ( ) @@ -108,7 +110,7 @@ Function ( GitGetHash GIT_ROOT OUT_HASH ) Message ( FATAL_ERROR "${GIT_ROOT} is not a git directory" ) EndIf ( ) - GitExecute ( "git -C ${GIT_ROOT} rev-parse HEAD" True HASH SUCCESS ) + GitExecute ( "${GIT_ROOT}" "git rev-parse HEAD" True HASH SUCCESS ) If ( NOT ${SUCCESS} ) Return ( ) EndIf ( ) @@ -126,7 +128,7 @@ Function ( GitGetIsDirty GIT_ROOT OUT_DIRTY ) Message ( FATAL_ERROR "${GIT_ROOT} is not a git directory" ) EndIf ( ) - GitExecute ( "git -C ${GIT_ROOT} status -s -uall" True DIRTY SUCCESS ) + GitExecute ( "${GIT_ROOT}" "git status -s -uall" True DIRTY SUCCESS ) If ( NOT ${SUCCESS} ) Return ( ) EndIf ( )