Fix akonadimodel.cpp:1: warning: unterminated character constant
[kdepim.git] / cmake / modules / FindKdeSubversion.cmake
blobea8a4c828a4537f126a3ff3e3383d8bcc7ed5721
1 # Modified to not be completely useless by Marc Mutz <mutz@kde.org>
2 # Changes made:
3 # 1. s/Subversion/KdeSubversion/
4 # 2. Remove LAST_CHANGED_LOG, which requires network access.
6 # - Extract information from a subversion working copy
7 # The module defines the following variables:
8 #  KdeSubversion_SVN_EXECUTABLE - path to svn command line client
9 #  KdeSubversion_VERSION_SVN - version of svn command line client
10 #  KdeSubversion_FOUND - true if the command line client was found
11 # If the command line client executable is found the macro
12 #  KdeSubversion_WC_INFO(<dir> <var-prefix>)
13 # is defined to extract information of a subversion working copy at
14 # a given location. The macro defines the following variables:
15 #  <var-prefix>_WC_URL - url of the repository (at <dir>)
16 #  <var-prefix>_WC_ROOT - root url of the repository
17 #  <var-prefix>_WC_REVISION - current revision
18 #  <var-prefix>_WC_LAST_CHANGED_AUTHOR - author of last commit
19 #  <var-prefix>_WC_LAST_CHANGED_DATE - date of last commit
20 #  <var-prefix>_WC_LAST_CHANGED_REV - revision of last commit
21 #  <var-prefix>_WC_LAST_CHANGED_LOG - last log of base revision
22 #  <var-prefix>_WC_INFO - output of command `svn info <dir>'
23 # Example usage:
24 #  FIND_PACKAGE(KdeSubversion)
25 #  IF(KdeSubversion_FOUND)
26 #    KdeSubversion_WC_INFO(${PROJECT_SOURCE_DIR} Project)
27 #    MESSAGE("Current revision is ${Project_WC_REVISION}")
28 #  ENDIF(KdeSubversion_FOUND)
30 # Copyright (c) 2006, Tristan Carel
31 # All rights reserved.
32 # Redistribution and use in source and binary forms, with or without
33 # modification, are permitted provided that the following conditions are met:
35 #     * Redistributions of source code must retain the above copyright
36 #       notice, this list of conditions and the following disclaimer.
37 #     * Redistributions in binary form must reproduce the above copyright
38 #       notice, this list of conditions and the following disclaimer in the
39 #       documentation and/or other materials provided with the distribution.
40 #     * Neither the name of the University of California, Berkeley nor the
41 #       names of its contributors may be used to endorse or promote products
42 #       derived from this software without specific prior written permission.
44 # THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
45 # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
46 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
47 # DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
48 # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
49 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
50 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
51 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
52 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
53 # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
55 # $Id: FindSubversion.cmake,v 1.1.2.1 2006/11/13 17:59:54 hoffman Exp $
57 SET(KdeSubversion_FOUND FALSE)
58 SET(KdeSubversion_SVN_FOUND FALSE)
60 FIND_PROGRAM(KdeSubversion_SVN_EXECUTABLE svn
61   DOC "subversion command line client")
62 MARK_AS_ADVANCED(KdeSubversion_SVN_EXECUTABLE)
64 IF(KdeSubversion_SVN_EXECUTABLE)
65   SET(KdeSubversion_SVN_FOUND TRUE)
66   SET(KdeSubversion_FOUND TRUE)
67   MACRO(KdeSubversion_WC_INFO dir prefix)
68     SET(ENV{LC_ALL} C )
69     EXECUTE_PROCESS(COMMAND "${KdeSubversion_SVN_EXECUTABLE}" --version
70       WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
71       OUTPUT_VARIABLE KdeSubversion_VERSION_SVN
72       OUTPUT_STRIP_TRAILING_WHITESPACE)
74     EXECUTE_PROCESS(COMMAND "${KdeSubversion_SVN_EXECUTABLE}" info ${dir}
75       OUTPUT_VARIABLE ${prefix}_WC_INFO
76       ERROR_VARIABLE KdeSubversion_svn_info_error
77       RESULT_VARIABLE KdeSubversion_svn_info_result
78       OUTPUT_STRIP_TRAILING_WHITESPACE)
80     IF(NOT ${KdeSubversion_svn_info_result} EQUAL 0)
81       MESSAGE(SEND_ERROR "Command \"${KdeSubversion_SVN_EXECUTABLE} info ${dir}\" failed with output:\n${KdeSubversion_svn_info_error}")
82     ELSE(NOT ${KdeSubversion_svn_info_result} EQUAL 0)
84       STRING(REGEX REPLACE "^(.*\n)?svn, version ([.0-9]+).*"
85         "\\2" KdeSubversion_VERSION_SVN "${KdeSubversion_VERSION_SVN}")
86       STRING(REGEX REPLACE "^(.*\n)?URL: ([^\n]+).*"
87         "\\2" ${prefix}_WC_URL "${${prefix}_WC_INFO}")
88       STRING(REGEX REPLACE "^(.*\n)?Revision: ([^\n]+).*"
89         "\\2" ${prefix}_WC_REVISION "${${prefix}_WC_INFO}")
90       STRING(REGEX REPLACE "^(.*\n)?Last Changed Author: ([^\n]+).*"
91         "\\2" ${prefix}_WC_LAST_CHANGED_AUTHOR "${${prefix}_WC_INFO}")
92       STRING(REGEX REPLACE "^(.*\n)?Last Changed Rev: ([^\n]+).*"
93         "\\2" ${prefix}_WC_LAST_CHANGED_REV "${${prefix}_WC_INFO}")
94       STRING(REGEX REPLACE "^(.*\n)?Last Changed Date: ([^\n]+).*"
95         "\\2" ${prefix}_WC_LAST_CHANGED_DATE "${${prefix}_WC_INFO}")
97     ENDIF(NOT ${KdeSubversion_svn_info_result} EQUAL 0)
99   ENDMACRO(KdeSubversion_WC_INFO)
101 ENDIF(KdeSubversion_SVN_EXECUTABLE)
103 IF(NOT KdeSubversion_FOUND)
104   IF(NOT KdeSubversion_FIND_QUIETLY)
105     MESSAGE(STATUS "Subversion was not found.")
106   ELSE(NOT KdeSubversion_FIND_QUIETLY)
107     IF(KdeSubversion_FIND_REQUIRED)
108       MESSAGE(FATAL_ERROR "Subversion was not found.")
109     ENDIF(KdeSubversion_FIND_REQUIRED)
110   ENDIF(NOT KdeSubversion_FIND_QUIETLY)
111 ENDIF(NOT KdeSubversion_FOUND)
113 # FindKdeSubversion.cmake ends here.