diff --git a/cmake/git_helper.cmake b/cmake/git_helper.cmake index 22ed057..8809ed3 100644 --- a/cmake/git_helper.cmake +++ b/cmake/git_helper.cmake @@ -118,3 +118,24 @@ Function ( GitGetHash GIT_ROOT OUT_HASH ) Set ( ${OUT_HASH} ${HASH} PARENT_SCOPE ) EndFunction ( ) + +# Checks if the given git repository has uncommitted changes +Function ( GitGetIsDirty GIT_ROOT OUT_DIRTY ) + + If ( NOT EXISTS "${GIT_ROOT}/.git" ) + Return ( ) + EndIf ( ) + + GitExecute ( "git -C ${CMAKE_CURRENT_SOURCE_DIR} status -s -uall" True DIRTY SUCCESS ) + If ( NOT ${SUCCESS} ) + Return ( ) + EndIf ( ) + + # dirty + If ( DIRTY ) + Set ( ${OUT_DIRTY} 1 PARENT_SCOPE ) + Else ( ) + Set ( ${OUT_DIRTY} 0 PARENT_SCOPE ) + EndIf ( ) + +EndFunction ( )