diff options
author | Alex Neundorf <neundorf@kde.org> | 2010-08-07 23:00:31 +0200 |
---|---|---|
committer | Alex Neundorf <neundorf@kde.org> | 2010-08-07 23:00:31 +0200 |
commit | 126db7b0609e368ea3cdd4509131566efa500e02 (patch) | |
tree | 600bf42fe9c1471fd4c571246b9247507331295e /Modules/FindSubversion.cmake | |
parent | 77d909b559be4c09a037a7a7eabef6fd76d77917 (diff) | |
download | cmake-126db7b0609e368ea3cdd4509131566efa500e02.tar.gz |
Improved version checking for FindSubversion using the new mode of FPHSA()
Alex
Diffstat (limited to 'Modules/FindSubversion.cmake')
-rw-r--r-- | Modules/FindSubversion.cmake | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/Modules/FindSubversion.cmake b/Modules/FindSubversion.cmake index 58a179d049..30220d1156 100644 --- a/Modules/FindSubversion.cmake +++ b/Modules/FindSubversion.cmake @@ -2,7 +2,12 @@ # The module defines the following variables: # Subversion_SVN_EXECUTABLE - path to svn command line client # Subversion_VERSION_SVN - version of svn command line client -# Subversion_FOUND - true if the command line client was found +# SUBVERSION_FOUND - true if the command line client was found +# Subversion_FOUND - same as SUBVERSION_FOUND, kept around for compatibility +# +# The minimum required version of Subversion can be specified using the +# standard syntax, e.g. FIND_PACKAGE(Subversion 1.4) +# # If the command line client executable is found the macro # Subversion_WC_INFO(<dir> <var-prefix>) # is defined to extract information of a subversion working copy at @@ -17,12 +22,12 @@ # <var-prefix>_WC_INFO - output of command `svn info <dir>' # Example usage: # FIND_PACKAGE(Subversion) -# IF(Subversion_FOUND) +# IF(SUBVERSION_FOUND) # Subversion_WC_INFO(${PROJECT_SOURCE_DIR} Project) # MESSAGE("Current revision is ${Project_WC_REVISION}") # Subversion_WC_LOG(${PROJECT_SOURCE_DIR} Project) # MESSAGE("Last changed log is ${Project_LAST_CHANGED_LOG}") -# ENDIF(Subversion_FOUND) +# ENDIF(SUBVERSION_FOUND) #============================================================================= # Copyright 2006-2009 Kitware, Inc. @@ -38,7 +43,6 @@ # (To distributed this file outside of CMake, substitute the full # License text for the above reference.) -SET(Subversion_FOUND FALSE) SET(Subversion_SVN_FOUND FALSE) FIND_PROGRAM(Subversion_SVN_EXECUTABLE svn @@ -47,7 +51,14 @@ MARK_AS_ADVANCED(Subversion_SVN_EXECUTABLE) IF(Subversion_SVN_EXECUTABLE) SET(Subversion_SVN_FOUND TRUE) - SET(Subversion_FOUND TRUE) + + 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}") + MACRO(Subversion_WC_INFO dir prefix) # the subversion commands should be executed with the C locale, otherwise @@ -55,11 +66,6 @@ IF(Subversion_SVN_EXECUTABLE) SET(_Subversion_SAVED_LC_ALL "$ENV{LC_ALL}") SET(ENV{LC_ALL} C) - EXECUTE_PROCESS(COMMAND ${Subversion_SVN_EXECUTABLE} --version - WORKING_DIRECTORY ${dir} - OUTPUT_VARIABLE Subversion_VERSION_SVN - OUTPUT_STRIP_TRAILING_WHITESPACE) - EXECUTE_PROCESS(COMMAND ${Subversion_SVN_EXECUTABLE} info ${dir} OUTPUT_VARIABLE ${prefix}_WC_INFO ERROR_VARIABLE Subversion_svn_info_error @@ -70,8 +76,6 @@ IF(Subversion_SVN_EXECUTABLE) 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)?svn, version ([.0-9]+).*" - "\\2" Subversion_VERSION_SVN "${Subversion_VERSION_SVN}") STRING(REGEX REPLACE "^(.*\n)?URL: ([^\n]+).*" "\\2" ${prefix}_WC_URL "${${prefix}_WC_INFO}") STRING(REGEX REPLACE "^(.*\n)?Revision: ([^\n]+).*" @@ -110,4 +114,7 @@ IF(Subversion_SVN_EXECUTABLE) ENDIF(Subversion_SVN_EXECUTABLE) INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(Subversion DEFAULT_MSG Subversion_SVN_EXECUTABLE) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(Subversion REQUIRED_VARS Subversion_SVN_EXECUTABLE + VERSION_VAR Subversion_VERSION_SVN ) + +SET(Subversion_FOUND ${SUBVERSION_FOUND}) |