Hi,

Attached is a patch to add support for Apache Xerces-C++.
This project is quite an old one, and doesn't have any
support for cmake at present.  This will allow cmake
projects to use current and older Xerces releases.


Regards,
Roger

-- 
  .''`.  Roger Leigh
 : :' :  Debian GNU/Linux    http://people.debian.org/~rleigh/
 `. `'   schroot and sbuild  http://alioth.debian.org/projects/buildd-tools
   `-    GPG Public Key      F33D 281D 470A B443 6756 147C 07B3 C8BC 4083 E800
>From a44354ecb762a28b6b47a5e7a61787e9aedac21b Mon Sep 17 00:00:00 2001
From: Roger Leigh <rle...@codelibre.net>
Date: Sat, 16 Aug 2014 10:42:39 +0000
Subject: [PATCH] FindXerces: New module to find Apache Xerces-C++

---
 Help/manual/cmake-modules.7.rst |  1 +
 Help/module/FindXerces.rst      |  1 +
 Modules/FindXerces.cmake        | 95 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 97 insertions(+)
 create mode 100644 Help/module/FindXerces.rst
 create mode 100644 Modules/FindXerces.cmake

diff --git a/Help/manual/cmake-modules.7.rst b/Help/manual/cmake-modules.7.rst
index 91fffe9..d7a3288 100644
--- a/Help/manual/cmake-modules.7.rst
+++ b/Help/manual/cmake-modules.7.rst
@@ -206,6 +206,7 @@ All Modules
    /module/FindWish
    /module/FindwxWidgets
    /module/FindwxWindows
+   /module/FindXerces
    /module/FindX11
    /module/FindXMLRPC
    /module/FindZLIB
diff --git a/Help/module/FindXerces.rst b/Help/module/FindXerces.rst
new file mode 100644
index 0000000..166d8dd
--- /dev/null
+++ b/Help/module/FindXerces.rst
@@ -0,0 +1 @@
+.. cmake-module:: ../../Modules/FindXerces.cmake
diff --git a/Modules/FindXerces.cmake b/Modules/FindXerces.cmake
new file mode 100644
index 0000000..1d9ed84
--- /dev/null
+++ b/Modules/FindXerces.cmake
@@ -0,0 +1,95 @@
+#.rst:
+# FindXerces
+# -------
+#
+# Find the Apache Xerces-C++ validating XML parser headers and libraries.
+#
+# Use this module by invoking find_package with the form::
+#
+#   find_package(Xerces
+#     [version] [EXACT]       # Minimum or EXACT version e.g. 3.1.1
+#     [REQUIRED])             # Fail with error if Xerces is not found
+#
+# This module reports information about the Xerces installation in
+# several variables.  General variables::
+#
+#   Xerces_VERSION - Xerces release version
+#   Xerces_FOUND - true if the main programs and libraries were found
+#   Xerces_LIBRARIES - component libraries to be linked
+#   Xerces_INCLUDE_DIR - the directory containing the Xerces headers
+#   Xerces_LIBRARY_DIR - the directory containing the Xerces libraries
+#
+# The following cache variables may also be set::
+#
+#   XERCES_INCLUDE_DIR - the directory containing the Xerces headers
+
+# Written by Roger Leigh <rle...@codelibre.net>
+
+#=============================================================================
+# Copyright 2014 University of Dundee
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# 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.
+#=============================================================================
+# (To distribute this file outside of CMake, substitute the full
+#  License text for the above reference.)
+
+# Derived from FindGTK2 _GTK2_GET_VERSION, modified for Xerces.
+function(_Xerces_GET_VERSION _OUT_major _OUT_minor _OUT_revision _xercesversion_hdr)
+    file(STRINGS ${_xercesversion_hdr} _contents REGEX "^[ \t]*#define XERCES_VERSION_.*")
+    if(_contents)
+        string(REGEX REPLACE ".*#define XERCES_VERSION_MAJOR[ \t]+([0-9]+).*" "\\1" ${_OUT_major} "${_contents}")
+        string(REGEX REPLACE ".*#define XERCES_VERSION_MINOR[ \t]+([0-9]+).*" "\\1" ${_OUT_minor} "${_contents}")
+        string(REGEX REPLACE ".*#define XERCES_VERSION_REVISION[ \t]+([0-9]+).*" "\\1" ${_OUT_revision} "${_contents}")
+
+        if(NOT ${_OUT_major} MATCHES "^[0-9]+$")
+            message(FATAL_ERROR "Version parsing failed for XERCES_VERSION_MAJOR!")
+        endif()
+        if(NOT ${_OUT_minor} MATCHES "^[0-9]+$")
+            message(FATAL_ERROR "Version parsing failed for XERCES_VERSION_MINOR!")
+        endif()
+        if(NOT ${_OUT_revision} MATCHES "^[0-9]+$")
+            message(FATAL_ERROR "Version parsing failed for XERCES_VERSION_REVISION!")
+        endif()
+
+        set("${_OUT_major}" "${${_OUT_major}}" PARENT_SCOPE)
+        set("${_OUT_minor}" "${${_OUT_minor}}" PARENT_SCOPE)
+        set("${_OUT_revision}" "${${_OUT_revision}}" PARENT_SCOPE)
+    else()
+        message(FATAL_ERROR "Include file ${_xercesversion_hdr} does not exist")
+    endif()
+endfunction(_Xerces_GET_VERSION)
+
+function(_Xerces_FIND)
+  # Find include directory
+  find_path(XERCES_INCLUDE_DIR
+            NAMES "xercesc/util/PlatformUtils.hpp"
+            DOC "Xerces-C++ include directory")
+  mark_as_advanced(XERCES_INCLUDE_DIR)
+  set(Xerces_INCLUDE_DIR "${XERCES_INCLUDE_DIR}" PARENT_SCOPE)
+
+  # Find all Xerces libraries
+  find_library(XERCES_LIBRARIES "xerces-c"
+    DOC "Xerces-C++ libraries")
+  mark_as_advanced(XERCES_LIBRARIES)
+  set(Xerces_LIBRARIES "${XERCES_LIBRARIES}" PARENT_SCOPE)
+
+  _Xerces_GET_VERSION(XERCES_VERSION_MAJOR XERCES_VERSION_MINOR XERCES_VERSION_REVISION "${XERCES_INCLUDE_DIR}/xercesc/util/XercesVersion.hpp")
+  set(_XERCES_VERSION "${XERCES_VERSION_MAJOR}.${XERCES_VERSION_MINOR}.${XERCES_VERSION_REVISION}" PARENT_SCOPE)
+endfunction(_Xerces_FIND)
+
+_Xerces_FIND()
+
+include(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(Xerces
+                                  REQUIRED_VARS Xerces_LIBRARIES
+                                                Xerces_INCLUDE_DIR
+                                                _XERCES_VERSION
+                                  VERSION_VAR _XERCES_VERSION
+                                  FAIL_MESSAGE "Failed to find all Xerces components")
+
+unset(_XERCES_VERSION)
-- 
1.9.4.msysgit.0

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers

Reply via email to