brintos

brintos / llvm-project-archived public Read only

0
0
Text · 859 B · b021010 Raw
37 lines · plain
1# - Returns a version string from Git tags2#3# This function inspects the annotated git tags for the project and returns a string4# into a CMake variable5#6#  get_git_version(<var>)7#8# - Example9#10# include(GetGitVersion)11# get_git_version(GIT_VERSION)12#13# Requires CMake 2.8.11+14find_package(Git)15 16if(__get_git_version)17  return()18endif()19set(__get_git_version INCLUDED)20 21function(get_git_version var)22  if(GIT_EXECUTABLE)23      execute_process(COMMAND ${GIT_EXECUTABLE} describe --tags --match "v[0-9]*.[0-9]*.[0-9]*" --abbrev=8 --dirty24          WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}25          RESULT_VARIABLE status26          OUTPUT_VARIABLE GIT_VERSION27          ERROR_QUIET)28      if(status)29          set(GIT_VERSION "v0.0.0")30      endif()31  else()32      set(GIT_VERSION "v0.0.0")33  endif()34 35  set(${var} ${GIT_VERSION} PARENT_SCOPE)36endfunction()37