瀏覽代碼

* Added git helper to get commit hash only

master
Klaus Nöske 6 年之前
父節點
當前提交
e59928a3a9
共有 1 個文件被更改,包括 18 次插入0 次删除
  1. +18
    -0
      cmake/git_helper.cmake

+ 18
- 0
cmake/git_helper.cmake 查看文件

@@ -100,3 +100,21 @@ Function ( GitGetVersion GIT_ROOT OUT_MAJOR OUT_MINOR OUT_PATCH OUT_BUILD OUT_HA
EndIf ( )

EndFunction ( )

# Get the git hash og the current commit
Function ( GitGetHash GIT_ROOT OUT_HASH )

If ( NOT EXISTS "${GIT_ROOT}/.git" )
Return ( )
EndIf ( )

GitExecute ( "git -C ${CMAKE_CURRENT_SOURCE_DIR} rev-parse HEAD" True HASH SUCCESS )
If ( NOT ${SUCCESS} )
Return ( )
EndIf ( )

# hash
String ( STRIP "${HASH}" HASH )
Set ( ${OUT_HASH} ${HASH} PARENT_SCOPE )

EndFunction ( )

Loading…
取消
儲存