FindGit.cmake 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. # The module defines the following variables:
  2. # GIT_EXECUTABLE - path to git command line client
  3. # GIT_FOUND - true if the command line client was found
  4. # Example usage:
  5. # find_package(Git)
  6. # if(GIT_FOUND)
  7. # message("git found: ${GIT_EXECUTABLE}")
  8. # endif()
  9. #=============================================================================
  10. # Copyright 2010 Kitware, Inc.
  11. #
  12. # Distributed under the OSI-approved BSD License (the "License");
  13. # see accompanying file Copyright.txt for details.
  14. #
  15. # This software is distributed WITHOUT ANY WARRANTY; without even the
  16. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  17. # See the License for more information.
  18. #=============================================================================
  19. # (To distribute this file outside of CMake, substitute the full
  20. # License text for the above reference.)
  21. # Look for 'git' or 'eg' (easy git)
  22. #
  23. set(git_names git eg)
  24. # Prefer .cmd variants on Windows unless running in a Makefile
  25. # in the MSYS shell.
  26. #
  27. if(WIN32)
  28. if(NOT CMAKE_GENERATOR MATCHES "MSYS")
  29. set(git_names git.cmd git eg.cmd eg)
  30. endif()
  31. endif()
  32. find_program(GIT_EXECUTABLE
  33. NAMES ${git_names}
  34. DOC "git command line client"
  35. )
  36. mark_as_advanced(GIT_EXECUTABLE)
  37. # Handle the QUIETLY and REQUIRED arguments and set GIT_FOUND to TRUE if
  38. # all listed variables are TRUE
  39. include(FindPackageHandleStandardArgs)
  40. find_package_handle_standard_args(Git DEFAULT_MSG GIT_EXECUTABLE)