Commit 775ef51d by Tobias Ulvgard Committed by Anton Danielsson

CMake check for git on the system

parent 41494129
...@@ -10,7 +10,8 @@ ...@@ -10,7 +10,8 @@
# include(GetGitVersion) # include(GetGitVersion)
# get_git_version(GIT_VERSION) # get_git_version(GIT_VERSION)
# #
# Requires CMake 2.6+ # Requires CMake 2.8.11+
find_package(Git)
if(__get_git_version) if(__get_git_version)
return() return()
...@@ -18,17 +19,22 @@ endif() ...@@ -18,17 +19,22 @@ endif()
set(__get_git_version INCLUDED) set(__get_git_version INCLUDED)
function(get_git_version var) function(get_git_version var)
execute_process(COMMAND git describe --match "v[0-9]*.[0-9]*.[0-9]*" --abbrev=8 if(GIT_EXECUTABLE)
RESULT_VARIABLE status execute_process(COMMAND git describe --match "v[0-9]*.[0-9]*.[0-9]*" --abbrev=8
OUTPUT_VARIABLE GIT_VERSION RESULT_VARIABLE status
ERROR_QUIET) OUTPUT_VARIABLE GIT_VERSION
if(${status}) ERROR_QUIET)
set(GIT_VERSION "v0.0.0") if(${status})
set(GIT_VERSION "v0.0.0")
else()
string(STRIP ${GIT_VERSION} GIT_VERSION)
string(REGEX REPLACE "-[0-9]+-g" "-" GIT_VERSION ${GIT_VERSION})
endif()
else() else()
string(STRIP ${GIT_VERSION} GIT_VERSION) set(GIT_VERSION "v0.0.0")
string(REGEX REPLACE "-[0-9]+-g" "-" GIT_VERSION ${GIT_VERSION})
endif() endif()
# Work out if the repository is dirty # Work out if the repository is dirty
execute_process(COMMAND git update-index -q --refresh execute_process(COMMAND git update-index -q --refresh
OUTPUT_QUIET OUTPUT_QUIET
......
Markdown is supported
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