File: GitBranch.cmake

package info (click to toggle)
itksnap 3.4.0-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 10,196 kB
  • ctags: 9,196
  • sloc: cpp: 62,895; sh: 175; makefile: 13
file content (23 lines) | stat: -rw-r--r-- 549 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# This code assigns the git branch to a variable
function(get_git_branch RESULTNAME)

  # Find Git and its libraries
  if(NOT GIT_FOUND)
    find_package(Git QUIET)
  endif(NOT GIT_FOUND)

  if(GIT_FOUND)

    # Call git to get branch id
    execute_process(
      COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
      WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
      OUTPUT_VARIABLE SNAP_VERSION_GIT_BRANCH
      OUTPUT_STRIP_TRAILING_WHITESPACE)

    set(${RESULTNAME} ${SNAP_VERSION_GIT_BRANCH} PARENT_SCOPE)

  endif(GIT_FOUND)

endfunction()