Dear Chuck, Thanks for looking at this. Please find attached a new copy of the patch which should address all your points. If you would like any further changes making, please just let me know.
Regards, Roger On Sat, Aug 16, 2014 at 11:11:42AM -0400, Chuck Atkins wrote: > Hey Roger, thanks for the contribution! A couple of points on find_module > convention, most of which you can find in > http://cmake.org/cmake/help/v3.0/manual/cmake-developer.7.html#modules. > Not all find modules currently shipped have been updated for these best > practices but new modules should try to stick to them. > > - Xerces_INCLUDE_DIR should be used to control the cache search but not > as a final output variable. Use Xerces_INCLUDE_DIRS. This helps with some > consistency since some libs may have only 1 include directory and others > have several. This way all find modules produce a Foo_INCLUDE_DIRS > variable instead of some producing _DIR and others producing _DIRS > - Xerces_LIBRARY_DIR is not actually used and should be removed from > documentation. > - Use Xerces_INCLUDE_DIR and Xerces_LIBRARY as the find_path and > find_library variables. After successfully passing the > FIND_PACKAGE_HANDLE_STANDARD_ARGS, then set the _INCLUDE_DIRS and > _LIBRARIES variables accordingly. > - Try to stick with either all mixed-case or all uppercase variable > names. No need to mix Xerces_FOO with XERCES_FOO. In this case, keeping > with all mixed case would be appropriate. > - Don't delete the version variable afterwards, it's good have set by > the find module as an output variable Xerces_VERSION. > > > - Chuck > > > On Sat, Aug 16, 2014 at 6:48 AM, Roger Leigh <rle...@codelibre.net> wrote: > > > 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 > > > > -- > > > > 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 > > -- .''`. 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 36ddc605d48f594667337869311afeeada18e532 Mon Sep 17 00:00:00 2001 From: Roger Leigh <rle...@codelibre.net> Date: Sun, 17 Aug 2014 12:58:16 +0100 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 | 99 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 101 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..3fb62cc --- /dev/null +++ b/Modules/FindXerces.cmake @@ -0,0 +1,99 @@ +#.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_INCLUDE_DIRS - the directory containing the Xerces headers +# Xerces_LIBRARIES - Xerces libraries to be linked +# +# The following cache variables may also be set:: +# +# Xerces_INCLUDE_DIR - the directory containing the Xerces headers +# Xerces_LIBRARY - the Xerces library + +# 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_LIBRARY "xerces-c" + DOC "Xerces-C++ libraries") + mark_as_advanced(Xerces_LIBRARY) + set(Xerces_LIBRARY "${Xerces_LIBRARY}" 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 + FOUND_VAR Xerces_FOUND + REQUIRED_VARS Xerces_LIBRARY + Xerces_INCLUDE_DIR + Xerces_VERSION + VERSION_VAR Xerces_VERSION + FAIL_MESSAGE "Failed to find Xerces") + +if(Xerces_FOUND) + set(Xerces_INCLUDE_DIRS "${Xerces_INCLUDE_DIR}") + set(Xerces_LIBRARIES "${Xerces_LIBRARY}") +endif(Xerces_FOUND) -- 2.1.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