summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
Diffstat (limited to 'Modules')
-rw-r--r--Modules/FindGit.cmake17
1 files changed, 16 insertions, 1 deletions
diff --git a/Modules/FindGit.cmake b/Modules/FindGit.cmake
index 503b640..f89d1af 100644
--- a/Modules/FindGit.cmake
+++ b/Modules/FindGit.cmake
@@ -1,6 +1,7 @@
# The module defines the following variables:
# GIT_EXECUTABLE - path to git command line client
# GIT_FOUND - true if the command line client was found
+# GIT_VERSION_STRING - the version of git found (since CMake 2.8.8)
# Example usage:
# find_package(Git)
# if(GIT_FOUND)
@@ -9,6 +10,7 @@
#=============================================================================
# Copyright 2010 Kitware, Inc.
+# Copyright 2012 Rolf Eike Beer <eike@sf-mail.de>
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
@@ -40,8 +42,21 @@ find_program(GIT_EXECUTABLE
)
mark_as_advanced(GIT_EXECUTABLE)
+if(GIT_EXECUTABLE)
+ execute_process(COMMAND ${GIT_EXECUTABLE} --version
+ OUTPUT_VARIABLE git_version
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ if (git_version MATCHES "^git version [0-9]")
+ string(REPLACE "git version " "" GIT_VERSION_STRING "${git_version}")
+ endif()
+ unset(git_version)
+endif(GIT_EXECUTABLE)
+
# Handle the QUIETLY and REQUIRED arguments and set GIT_FOUND to TRUE if
# all listed variables are TRUE
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
-find_package_handle_standard_args(Git DEFAULT_MSG GIT_EXECUTABLE)
+find_package_handle_standard_args(Git
+ REQUIRED_VARS GIT_EXECUTABLE
+ VERSION_VAR GIT_VERSION_STRING)