2006-10-30 23:30:59 +03:00
|
|
|
# - Extract information from a subversion working copy
|
|
|
|
# The module defines the following variables:
|
|
|
|
# Subversion_SVN_EXECUTABLE - path to svn command line client
|
|
|
|
# Subversion_VERSION_SVN - version of svn command line client
|
2010-08-14 23:25:22 +04:00
|
|
|
# Subversion_FOUND - true if the command line client was found
|
|
|
|
# SUBVERSION_FOUND - same as Subversion_FOUND, set for compatiblity reasons
|
2010-08-08 01:00:31 +04:00
|
|
|
#
|
|
|
|
# The minimum required version of Subversion can be specified using the
|
|
|
|
# standard syntax, e.g. FIND_PACKAGE(Subversion 1.4)
|
|
|
|
#
|
2010-09-13 15:13:12 +04:00
|
|
|
# If the command line client executable is found two macros are defined:
|
2006-10-30 23:30:59 +03:00
|
|
|
# Subversion_WC_INFO(<dir> <var-prefix>)
|
2010-09-13 15:13:12 +04:00
|
|
|
# Subversion_WC_LOG(<dir> <var-prefix>)
|
|
|
|
# Subversion_WC_INFO extracts information of a subversion working copy at
|
|
|
|
# a given location. This macro defines the following variables:
|
2006-10-30 23:30:59 +03:00
|
|
|
# <var-prefix>_WC_URL - url of the repository (at <dir>)
|
|
|
|
# <var-prefix>_WC_ROOT - root url of the repository
|
|
|
|
# <var-prefix>_WC_REVISION - current revision
|
|
|
|
# <var-prefix>_WC_LAST_CHANGED_AUTHOR - author of last commit
|
|
|
|
# <var-prefix>_WC_LAST_CHANGED_DATE - date of last commit
|
|
|
|
# <var-prefix>_WC_LAST_CHANGED_REV - revision of last commit
|
|
|
|
# <var-prefix>_WC_INFO - output of command `svn info <dir>'
|
2010-09-13 15:13:12 +04:00
|
|
|
# Subversion_WC_LOG retrieves the log message of the base revision of a
|
|
|
|
# subversion working copy at a given location. This macro defines the
|
|
|
|
# variable:
|
|
|
|
# <var-prefix>_LAST_CHANGED_LOG - last log of base revision
|
2006-10-30 23:30:59 +03:00
|
|
|
# Example usage:
|
|
|
|
# FIND_PACKAGE(Subversion)
|
2010-08-08 01:00:31 +04:00
|
|
|
# IF(SUBVERSION_FOUND)
|
2006-10-30 23:30:59 +03:00
|
|
|
# Subversion_WC_INFO(${PROJECT_SOURCE_DIR} Project)
|
|
|
|
# MESSAGE("Current revision is ${Project_WC_REVISION}")
|
2008-05-19 18:03:59 +04:00
|
|
|
# Subversion_WC_LOG(${PROJECT_SOURCE_DIR} Project)
|
|
|
|
# MESSAGE("Last changed log is ${Project_LAST_CHANGED_LOG}")
|
2010-08-08 01:00:31 +04:00
|
|
|
# ENDIF(SUBVERSION_FOUND)
|
2006-10-30 23:30:59 +03:00
|
|
|
|
2009-09-28 19:45:50 +04:00
|
|
|
#=============================================================================
|
|
|
|
# Copyright 2006-2009 Kitware, Inc.
|
|
|
|
# Copyright 2006 Tristan Carel
|
2006-10-30 23:30:59 +03:00
|
|
|
#
|
2009-09-28 19:45:50 +04:00
|
|
|
# Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
# see accompanying file Copyright.txt for details.
|
2006-10-30 23:30:59 +03:00
|
|
|
#
|
2009-09-28 19:45:50 +04:00
|
|
|
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
# See the License for more information.
|
|
|
|
#=============================================================================
|
2010-08-07 04:48:47 +04:00
|
|
|
# (To distribute this file outside of CMake, substitute the full
|
2009-09-28 19:45:50 +04:00
|
|
|
# License text for the above reference.)
|
2006-10-30 23:30:59 +03:00
|
|
|
|
|
|
|
FIND_PROGRAM(Subversion_SVN_EXECUTABLE svn
|
|
|
|
DOC "subversion command line client")
|
|
|
|
MARK_AS_ADVANCED(Subversion_SVN_EXECUTABLE)
|
|
|
|
|
|
|
|
IF(Subversion_SVN_EXECUTABLE)
|
|
|
|
|
2010-08-08 01:00:31 +04:00
|
|
|
EXECUTE_PROCESS(COMMAND ${Subversion_SVN_EXECUTABLE} --version
|
|
|
|
OUTPUT_VARIABLE Subversion_VERSION_SVN
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
|
|
|
|
|
|
STRING(REGEX REPLACE "^(.*\n)?svn, version ([.0-9]+).*"
|
|
|
|
"\\2" Subversion_VERSION_SVN "${Subversion_VERSION_SVN}")
|
|
|
|
|
2006-10-30 23:30:59 +03:00
|
|
|
MACRO(Subversion_WC_INFO dir prefix)
|
2008-05-19 18:03:59 +04:00
|
|
|
# the subversion commands should be executed with the C locale, otherwise
|
|
|
|
# the message (which are parsed) may be translated, Alex
|
|
|
|
SET(_Subversion_SAVED_LC_ALL "$ENV{LC_ALL}")
|
|
|
|
SET(ENV{LC_ALL} C)
|
|
|
|
|
2006-10-30 23:30:59 +03:00
|
|
|
EXECUTE_PROCESS(COMMAND ${Subversion_SVN_EXECUTABLE} info ${dir}
|
|
|
|
OUTPUT_VARIABLE ${prefix}_WC_INFO
|
|
|
|
ERROR_VARIABLE Subversion_svn_info_error
|
|
|
|
RESULT_VARIABLE Subversion_svn_info_result
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
|
|
|
|
|
|
IF(NOT ${Subversion_svn_info_result} EQUAL 0)
|
|
|
|
MESSAGE(SEND_ERROR "Command \"${Subversion_SVN_EXECUTABLE} info ${dir}\" failed with output:\n${Subversion_svn_info_error}")
|
|
|
|
ELSE(NOT ${Subversion_svn_info_result} EQUAL 0)
|
|
|
|
|
|
|
|
STRING(REGEX REPLACE "^(.*\n)?URL: ([^\n]+).*"
|
|
|
|
"\\2" ${prefix}_WC_URL "${${prefix}_WC_INFO}")
|
2010-09-13 15:13:12 +04:00
|
|
|
STRING(REGEX REPLACE "^(.*\n)?Repository Root: ([^\n]+).*"
|
|
|
|
"\\2" ${prefix}_WC_ROOT "${${prefix}_WC_INFO}")
|
2006-10-30 23:30:59 +03:00
|
|
|
STRING(REGEX REPLACE "^(.*\n)?Revision: ([^\n]+).*"
|
|
|
|
"\\2" ${prefix}_WC_REVISION "${${prefix}_WC_INFO}")
|
|
|
|
STRING(REGEX REPLACE "^(.*\n)?Last Changed Author: ([^\n]+).*"
|
|
|
|
"\\2" ${prefix}_WC_LAST_CHANGED_AUTHOR "${${prefix}_WC_INFO}")
|
|
|
|
STRING(REGEX REPLACE "^(.*\n)?Last Changed Rev: ([^\n]+).*"
|
|
|
|
"\\2" ${prefix}_WC_LAST_CHANGED_REV "${${prefix}_WC_INFO}")
|
|
|
|
STRING(REGEX REPLACE "^(.*\n)?Last Changed Date: ([^\n]+).*"
|
|
|
|
"\\2" ${prefix}_WC_LAST_CHANGED_DATE "${${prefix}_WC_INFO}")
|
|
|
|
|
|
|
|
ENDIF(NOT ${Subversion_svn_info_result} EQUAL 0)
|
|
|
|
|
2008-05-19 18:03:59 +04:00
|
|
|
# restore the previous LC_ALL
|
|
|
|
SET(ENV{LC_ALL} ${_Subversion_SAVED_LC_ALL})
|
|
|
|
|
|
|
|
ENDMACRO(Subversion_WC_INFO)
|
|
|
|
|
|
|
|
MACRO(Subversion_WC_LOG dir prefix)
|
|
|
|
# This macro can block if the certificate is not signed:
|
|
|
|
# svn ask you to accept the certificate and wait for your answer
|
|
|
|
# This macro requires a svn server network access (Internet most of the time)
|
|
|
|
# and can also be slow since it access the svn server
|
2006-10-30 23:30:59 +03:00
|
|
|
EXECUTE_PROCESS(COMMAND
|
|
|
|
${Subversion_SVN_EXECUTABLE} log -r BASE ${dir}
|
2008-05-19 18:03:59 +04:00
|
|
|
OUTPUT_VARIABLE ${prefix}_LAST_CHANGED_LOG
|
2006-10-30 23:30:59 +03:00
|
|
|
ERROR_VARIABLE Subversion_svn_log_error
|
|
|
|
RESULT_VARIABLE Subversion_svn_log_result
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
|
|
|
|
|
|
IF(NOT ${Subversion_svn_log_result} EQUAL 0)
|
|
|
|
MESSAGE(SEND_ERROR "Command \"${Subversion_SVN_EXECUTABLE} log -r BASE ${dir}\" failed with output:\n${Subversion_svn_log_error}")
|
|
|
|
ENDIF(NOT ${Subversion_svn_log_result} EQUAL 0)
|
2008-05-19 18:03:59 +04:00
|
|
|
ENDMACRO(Subversion_WC_LOG)
|
2006-10-30 23:30:59 +03:00
|
|
|
|
|
|
|
ENDIF(Subversion_SVN_EXECUTABLE)
|
|
|
|
|
2010-04-11 22:31:17 +04:00
|
|
|
INCLUDE(FindPackageHandleStandardArgs)
|
2010-08-08 01:00:31 +04:00
|
|
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Subversion REQUIRED_VARS Subversion_SVN_EXECUTABLE
|
|
|
|
VERSION_VAR Subversion_VERSION_SVN )
|
2010-08-04 10:51:55 +04:00
|
|
|
|
|
|
|
# for compatibility
|
|
|
|
SET(Subversion_FOUND ${SUBVERSION_FOUND})
|
|
|
|
SET(Subversion_SVN_FOUND ${SUBVERSION_FOUND})
|