3 function(get_git_hash GIT_DIR _hashvar)
4 execute_process(COMMAND
5 "${GIT_EXECUTABLE}" rev-parse HEAD
6 WORKING_DIRECTORY ${GIT_DIR}
7 OUTPUT_VARIABLE HEAD_HASH
10 string(REGEX REPLACE "\n$" "" HEAD_HASH "${HEAD_HASH}")
11 set(${_hashvar} "${HEAD_HASH}" PARENT_SCOPE)
13 set(${_hashvar} "SHA1-NOT FOUND" PARENT_SCOPE)
17 function(get_git_tag GIT_DIR FALLBACK _gittag)
18 execute_process(COMMAND
19 "${GIT_EXECUTABLE}" describe --tags
20 WORKING_DIRECTORY ${GIT_DIR}
21 OUTPUT_VARIABLE GIT_TAG
24 string(REGEX REPLACE "\n$" "" GIT_TAG "${GIT_TAG}")
25 set(${_gittag} "${GIT_TAG}" PARENT_SCOPE)
27 set(${_gittag} "${FALLBACK}-fallback" PARENT_SCOPE)
31 function(get_git_version
32 GIT_TAG_VERSION _version_major _version_minor _version_build)
34 "^v([0-9]+)\\..*" "\\1" VERSION_MAJOR "${GIT_TAG_VERSION}")
36 "^v[0-9]+\\.([0-9]+).*" "\\1" VERSION_MINOR "${GIT_TAG_VERSION}")
38 "^v[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" VERSION_BUILD "${GIT_TAG_VERSION}")
39 set(${_version_major} "${VERSION_MAJOR}" PARENT_SCOPE)
40 set(${_version_minor} "${VERSION_MINOR}" PARENT_SCOPE)
41 set(${_version_build} "${VERSION_BUILD}" PARENT_SCOPE)