diff options
Diffstat (limited to 'externals')
-rw-r--r-- | externals/cmake-modules/GetGitRevisionDescription.cmake | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/externals/cmake-modules/GetGitRevisionDescription.cmake b/externals/cmake-modules/GetGitRevisionDescription.cmake index 2b9cde061..087f5deea 100644 --- a/externals/cmake-modules/GetGitRevisionDescription.cmake +++ b/externals/cmake-modules/GetGitRevisionDescription.cmake @@ -80,6 +80,34 @@ function(get_git_head_revision _refspecvar _hashvar) set(${_hashvar} "${HEAD_HASH}" PARENT_SCOPE) endfunction() +function(git_branch_name _var) + if(NOT GIT_FOUND) + find_package(Git QUIET) + endif() + + if(NOT GIT_FOUND) + set(${_var} "GIT-NOTFOUND" PARENT_SCOPE) + return() + endif() + + execute_process(COMMAND + "${GIT_EXECUTABLE}" + rev-parse --abbrev-ref HEAD + WORKING_DIRECTORY + "${CMAKE_SOURCE_DIR}" + RESULT_VARIABLE + res + OUTPUT_VARIABLE + out + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + if(NOT res EQUAL 0) + set(out "${out}-${res}-NOTFOUND") + endif() + + set(${_var} "${out}" PARENT_SCOPE) +endfunction() + function(git_describe _var) if(NOT GIT_FOUND) find_package(Git QUIET) |