summaryrefslogtreecommitdiff
path: root/Modules/FindSubversion.cmake
diff options
context:
space:
mode:
authorJason Heeris <jason.heeris@gmail.com>2018-08-16 10:57:35 +1000
committerBrad King <brad.king@kitware.com>2018-09-07 16:17:28 -0400
commit68d015fc94af6e39212b051336d7dc7f5c18d1d2 (patch)
tree95155d431bc1a4ba6eb72eaa8db4b1464cc8f7ee /Modules/FindSubversion.cmake
parentf782759ed0997eb3d71e1187a829da62668ed5d2 (diff)
downloadcmake-68d015fc94af6e39212b051336d7dc7f5c18d1d2.tar.gz
FindSubversion: Add Subversion_WC_INFO option to suppress failures
Subversion fails when the directory is not actually under its control. Allow projects to tolerate this case optionally. Fixes: #18264
Diffstat (limited to 'Modules/FindSubversion.cmake')
-rw-r--r--Modules/FindSubversion.cmake33
1 files changed, 21 insertions, 12 deletions
diff --git a/Modules/FindSubversion.cmake b/Modules/FindSubversion.cmake
index 537d3b2412..e18ae880f7 100644
--- a/Modules/FindSubversion.cmake
+++ b/Modules/FindSubversion.cmake
@@ -19,17 +19,21 @@
#
#
# The minimum required version of Subversion can be specified using the
-# standard syntax, e.g. find_package(Subversion 1.4)
+# standard syntax, e.g. ``find_package(Subversion 1.4)``.
#
# If the command line client executable is found two macros are defined:
#
# ::
#
-# Subversion_WC_INFO(<dir> <var-prefix>)
+# Subversion_WC_INFO(<dir> <var-prefix> [IGNORE_SVN_FAILURE])
# 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:
+# ``Subversion_WC_INFO`` extracts information of a subversion working copy at a
+# given location. This macro defines the following variables if running
+# Subversion's ``info`` command on ``<dir>`` succeeds; otherwise a
+# ``SEND_ERROR`` message is generated. The error can be ignored by providing the
+# ``IGNORE_SVN_FAILURE`` option, which causes these variables to remain
+# undefined.
#
# ::
#
@@ -41,9 +45,8 @@
# <var-prefix>_WC_LAST_CHANGED_REV - revision of last commit
# <var-prefix>_WC_INFO - output of command `svn info <dir>'
#
-# 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:
+# ``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:
#
# ::
#
@@ -84,6 +87,14 @@ if(Subversion_SVN_EXECUTABLE)
"\\2" Subversion_VERSION_SVN "${Subversion_VERSION_SVN}")
macro(Subversion_WC_INFO dir prefix)
+
+ cmake_parse_arguments(
+ "Subversion_WC_INFO"
+ "IGNORE_SVN_FAILURE"
+ "" ""
+ ${ARGN}
+ )
+
# 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}")
@@ -95,10 +106,7 @@ if(Subversion_SVN_EXECUTABLE)
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()
-
+ if(${Subversion_svn_info_result} EQUAL 0)
string(REGEX REPLACE "^(.*\n)?URL: ([^\n]+).*"
"\\2" ${prefix}_WC_URL "${${prefix}_WC_INFO}")
string(REGEX REPLACE "^(.*\n)?Repository Root: ([^\n]+).*"
@@ -111,7 +119,8 @@ if(Subversion_SVN_EXECUTABLE)
"\\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}")
-
+ elseif(NOT Subversion_WC_INFO_IGNORE_SVN_FAILURE)
+ message(SEND_ERROR "Command \"${Subversion_SVN_EXECUTABLE} info ${dir}\" failed with output:\n${Subversion_svn_info_error}")
endif()
# restore the previous LC_ALL