FindHg.cmake 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. # The module defines the following variables:
  2. # HG_EXECUTABLE - path to mercurial command line client (hg)
  3. # HG_FOUND - true if the command line client was found
  4. # HG_VERSION_STRING - the version of mercurial found
  5. # Example usage:
  6. # find_package(Hg)
  7. # if(HG_FOUND)
  8. # message("hg found: ${HG_EXECUTABLE}")
  9. # endif()
  10. #=============================================================================
  11. # Copyright 2010-2012 Kitware, Inc.
  12. # Copyright 2012 Rolf Eike Beer <[email protected]>
  13. #
  14. # Distributed under the OSI-approved BSD License (the "License");
  15. # see accompanying file Copyright.txt for details.
  16. #
  17. # This software is distributed WITHOUT ANY WARRANTY; without even the
  18. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  19. # See the License for more information.
  20. #=============================================================================
  21. # (To distribute this file outside of CMake, substitute the full
  22. # License text for the above reference.)
  23. find_program(HG_EXECUTABLE
  24. NAMES hg
  25. PATH_SUFFIXES Mercurial
  26. DOC "hg command line client"
  27. )
  28. mark_as_advanced(HG_EXECUTABLE)
  29. if(HG_EXECUTABLE)
  30. execute_process(COMMAND ${HG_EXECUTABLE} --version
  31. OUTPUT_VARIABLE hg_version
  32. ERROR_QUIET
  33. OUTPUT_STRIP_TRAILING_WHITESPACE)
  34. if(hg_version MATCHES "^Mercurial Distributed SCM \\(version ([0-9][^)]*)\\)")
  35. set(HG_VERSION_STRING "${CMAKE_MATCH_1}")
  36. endif()
  37. unset(hg_version)
  38. endif()
  39. # Handle the QUIETLY and REQUIRED arguments and set HG_FOUND to TRUE if
  40. # all listed variables are TRUE
  41. include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
  42. find_package_handle_standard_args(Hg
  43. REQUIRED_VARS HG_EXECUTABLE
  44. VERSION_VAR HG_VERSION_STRING)