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 ( )