Merge topic 'FindHg-add-WC_INFO'
bcefbe73
FindHg: Add Hg_WC_INFO macro8993df6c
FindHg: Search for TortoiseHg
This commit is contained in:
commit
507236c511
|
@ -2,7 +2,7 @@
|
||||||
# FindHg
|
# FindHg
|
||||||
# ------
|
# ------
|
||||||
#
|
#
|
||||||
#
|
# Extract information from a mercurial working copy.
|
||||||
#
|
#
|
||||||
# The module defines the following variables:
|
# The module defines the following variables:
|
||||||
#
|
#
|
||||||
|
@ -12,6 +12,20 @@
|
||||||
# HG_FOUND - true if the command line client was found
|
# HG_FOUND - true if the command line client was found
|
||||||
# HG_VERSION_STRING - the version of mercurial found
|
# HG_VERSION_STRING - the version of mercurial found
|
||||||
#
|
#
|
||||||
|
# If the command line client executable is found the following macro is defined:
|
||||||
|
#
|
||||||
|
# ::
|
||||||
|
#
|
||||||
|
# HG_WC_INFO(<dir> <var-prefix>)
|
||||||
|
#
|
||||||
|
# Hg_WC_INFO extracts information of a mercurial working copy
|
||||||
|
# at a given location. This macro defines the following variables:
|
||||||
|
#
|
||||||
|
# ::
|
||||||
|
#
|
||||||
|
# <var-prefix>_WC_CHANGESET - current changeset
|
||||||
|
# <var-prefix>_WC_REVISION - current revision
|
||||||
|
#
|
||||||
# Example usage:
|
# Example usage:
|
||||||
#
|
#
|
||||||
# ::
|
# ::
|
||||||
|
@ -19,11 +33,15 @@
|
||||||
# find_package(Hg)
|
# find_package(Hg)
|
||||||
# if(HG_FOUND)
|
# if(HG_FOUND)
|
||||||
# message("hg found: ${HG_EXECUTABLE}")
|
# message("hg found: ${HG_EXECUTABLE}")
|
||||||
|
# HG_WC_INFO(${PROJECT_SOURCE_DIR} Project)
|
||||||
|
# message("Current revision is ${Project_WC_REVISION}")
|
||||||
|
# message("Current changeset is ${Project_WC_CHANGESET}")
|
||||||
# endif()
|
# endif()
|
||||||
|
|
||||||
#=============================================================================
|
#=============================================================================
|
||||||
# Copyright 2010-2012 Kitware, Inc.
|
# Copyright 2010-2012 Kitware, Inc.
|
||||||
# Copyright 2012 Rolf Eike Beer <eike@sf-mail.de>
|
# Copyright 2012 Rolf Eike Beer <eike@sf-mail.de>
|
||||||
|
# Copyright 2014 Matthaeus G. Chajdas
|
||||||
#
|
#
|
||||||
# Distributed under the OSI-approved BSD License (the "License");
|
# Distributed under the OSI-approved BSD License (the "License");
|
||||||
# see accompanying file Copyright.txt for details.
|
# see accompanying file Copyright.txt for details.
|
||||||
|
@ -37,6 +55,8 @@
|
||||||
|
|
||||||
find_program(HG_EXECUTABLE
|
find_program(HG_EXECUTABLE
|
||||||
NAMES hg
|
NAMES hg
|
||||||
|
PATHS
|
||||||
|
[HKEY_LOCAL_MACHINE\\Software\\TortoiseHG]
|
||||||
PATH_SUFFIXES Mercurial
|
PATH_SUFFIXES Mercurial
|
||||||
DOC "hg command line client"
|
DOC "hg command line client"
|
||||||
)
|
)
|
||||||
|
@ -51,6 +71,21 @@ if(HG_EXECUTABLE)
|
||||||
set(HG_VERSION_STRING "${CMAKE_MATCH_1}")
|
set(HG_VERSION_STRING "${CMAKE_MATCH_1}")
|
||||||
endif()
|
endif()
|
||||||
unset(hg_version)
|
unset(hg_version)
|
||||||
|
|
||||||
|
macro(HG_WC_INFO dir prefix)
|
||||||
|
execute_process(COMMAND ${HG_EXECUTABLE} id -i -n
|
||||||
|
WORKING_DIRECTORY ${dir}
|
||||||
|
RESULT_VARIABLE hg_id_result
|
||||||
|
ERROR_VARIABLE hg_id_error
|
||||||
|
OUTPUT_VARIABLE ${prefix}_WC_DATA
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
|
if(NOT ${hg_id_result} EQUAL 0)
|
||||||
|
message(SEND_ERROR "Command \"${HG_EXECUTBALE} id -n\" in directory ${dir} failed with output:\n${hg_id_error}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
string(REGEX REPLACE "([0-9a-f]+)\\+? [0-9]+\\+?" "\\1" ${prefix}_WC_CHANGESET ${${prefix}_WC_DATA})
|
||||||
|
string(REGEX REPLACE "[0-9a-f]+\\+? ([0-9]+)\\+?" "\\1" ${prefix}_WC_REVISION ${${prefix}_WC_DATA})
|
||||||
|
endmacro(HG_WC_INFO)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Handle the QUIETLY and REQUIRED arguments and set HG_FOUND to TRUE if
|
# Handle the QUIETLY and REQUIRED arguments and set HG_FOUND to TRUE if
|
||||||
|
|
Loading…
Reference in New Issue