diff options
author | Rolf Eike Beer <eike@sf-mail.de> | 2012-01-23 18:46:08 (GMT) |
---|---|---|
committer | Rolf Eike Beer <eike@sf-mail.de> | 2012-01-23 19:10:42 (GMT) |
commit | a803a622d052e6b50873f6bf6a3ab224f656333f (patch) | |
tree | 4361fbb30b7722f090adb2b8805b9435de224094 /Modules/FindGit.cmake | |
parent | 86c9604f98b2271401cf7a53c251be51af15278c (diff) | |
download | CMake-a803a622d052e6b50873f6bf6a3ab224f656333f.zip CMake-a803a622d052e6b50873f6bf6a3ab224f656333f.tar.gz CMake-a803a622d052e6b50873f6bf6a3ab224f656333f.tar.bz2 |
FindGit: support version number
Diffstat (limited to 'Modules/FindGit.cmake')
-rw-r--r-- | Modules/FindGit.cmake | 17 |
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) |