aheinecke@533: # The module defines the following variables: aheinecke@533: # HG_EXECUTABLE - path to mercurial command line client (hg) aheinecke@533: # HG_FOUND - true if the command line client was found aheinecke@533: # HG_VERSION_STRING - the version of mercurial found aheinecke@533: # Example usage: aheinecke@533: # find_package(Hg) aheinecke@533: # if(HG_FOUND) aheinecke@533: # message("hg found: ${HG_EXECUTABLE}") aheinecke@533: # endif() aheinecke@533: aheinecke@533: #============================================================================= aheinecke@533: # Copyright 2010-2012 Kitware, Inc. aheinecke@533: # Copyright 2012 Rolf Eike Beer aheinecke@533: # aheinecke@533: # Distributed under the OSI-approved BSD License (the "License"); aheinecke@533: # see accompanying file Copyright.txt for details. aheinecke@533: # aheinecke@533: # This software is distributed WITHOUT ANY WARRANTY; without even the aheinecke@533: # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. aheinecke@533: # See the License for more information. aheinecke@533: #============================================================================= aheinecke@533: # (To distribute this file outside of CMake, substitute the full aheinecke@533: # License text for the above reference.) aheinecke@533: aheinecke@533: find_program(HG_EXECUTABLE aheinecke@533: NAMES hg aheinecke@533: PATH_SUFFIXES Mercurial aheinecke@533: DOC "hg command line client" aheinecke@533: ) aheinecke@533: mark_as_advanced(HG_EXECUTABLE) aheinecke@533: aheinecke@533: if(HG_EXECUTABLE) aheinecke@533: execute_process(COMMAND ${HG_EXECUTABLE} --version aheinecke@533: OUTPUT_VARIABLE hg_version aheinecke@533: ERROR_QUIET aheinecke@533: OUTPUT_STRIP_TRAILING_WHITESPACE) aheinecke@533: if(hg_version MATCHES "^Mercurial Distributed SCM \\(version ([0-9][^)]*)\\)") aheinecke@533: set(HG_VERSION_STRING "${CMAKE_MATCH_1}") aheinecke@533: endif() aheinecke@533: unset(hg_version) aheinecke@533: endif() aheinecke@533: aheinecke@533: # Handle the QUIETLY and REQUIRED arguments and set HG_FOUND to TRUE if aheinecke@533: # all listed variables are TRUE aheinecke@535: include(FindPackageHandleStandardArgs) aheinecke@533: find_package_handle_standard_args(Hg aheinecke@533: REQUIRED_VARS HG_EXECUTABLE aheinecke@533: VERSION_VAR HG_VERSION_STRING)