1 # - Returns a version string from Git tags
3 # This function inspects the annotated git tags for the project and returns a string
4 # into a CMake variable
6 # get_git_version(<var>)
10 # include(GetGitVersion)
11 # get_git_version(GIT_VERSION)
13 # Requires CMake 2.8.11+
19 set(__get_git_version INCLUDED)
21 function(get_git_version var)
23 execute_process(COMMAND ${GIT_EXECUTABLE} describe --tags --match "v[0-9]*.[0-9]*.[0-9]*" --abbrev=8 --dirty
24 WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
25 RESULT_VARIABLE status
26 OUTPUT_VARIABLE GIT_VERSION
29 set(GIT_VERSION "v0.0.0")
32 set(GIT_VERSION "v0.0.0")
35 set(${var} ${GIT_VERSION} PARENT_SCOPE)