From 80a040ac772132a8d8e7385c0261f545adc88aee Mon Sep 17 00:00:00 2001 From: bunnei Date: Wed, 23 Apr 2014 19:13:00 -0700 Subject: fixes to scm_rev generation to make it conistent with windows build --- .../cmake-modules/GetGitRevisionDescription.cmake | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'externals/cmake-modules') 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) -- cgit v1.2.3