Commit 3336af16 authored by Steffen Vogel's avatar Steffen Vogel 🎅🏼
Browse files

cmake: add new function to get branch name

parent 455557c2
......@@ -107,7 +107,6 @@ function(git_describe _var)
execute_process(COMMAND
"${GIT_EXECUTABLE}"
describe
${ARGN}
WORKING_DIRECTORY
"${CMAKE_SOURCE_DIR}"
......@@ -128,3 +127,32 @@ function(git_get_exact_tag _var)
git_describe(out --exact-match ${ARGN})
set(${_var} "${out}" PARENT_SCOPE)
endfunction()
function(git_rev_parse _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
${ARGN}
WORKING_DIRECTORY
"${CMAKE_SOURCE_DIR}"
RESULT_VARIABLE
res
OUTPUT_VARIABLE
out
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT res EQUAL 0)
set(${_var} "REFSPEC-UNKOWN" PARENT_SCOPE)
return()
endif()
set(${_var} "${out}" PARENT_SCOPE)
endfunction()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment