On Sun, Aug 17, 2014 at 03:46:14PM +0200, Rolf Eike Beer wrote: > > Sorry for the naïve question, but the find_package docs also mentions > > setting package_VERSION_COUNT but I don't see any examples of this in > > cmake git. Is setting the MAJOR/MINOR/PATCH versions here correct or > > redundant or plain wrong? Or all handled internally by > > FIND_PACKAGE_HANDLE_STANDARD_ARGS? I'm just a little confused between > > the difference between the documentation and the actual examples in > > Modules/Find*. > > That variable is automatically set by CMake and will tell you how many > components were found in the version passed to find_package.
Ah, OK. I've tidied up the version handling as you suggested, new patch attached. 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 29c8140cd2c4446fd71b82a539a747a4eeec3397 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 | 92 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 94 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..ebaed4e --- /dev/null +++ b/Modules/FindXerces.cmake @@ -0,0 +1,92 @@ +#.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_FOUND - true if the Xerces headers and libraries were found +# Xerces_VERSION - Xerces release version +# 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 version_hdr) + file(STRINGS ${version_hdr} _contents REGEX "^[ \t]*#define XERCES_VERSION_.*") + if(_contents) + string(REGEX REPLACE ".*#define XERCES_VERSION_MAJOR[ \t]+([0-9]+).*" "\\1" Xerces_MAJOR "${_contents}") + string(REGEX REPLACE ".*#define XERCES_VERSION_MINOR[ \t]+([0-9]+).*" "\\1" Xerces_MINOR "${_contents}") + string(REGEX REPLACE ".*#define XERCES_VERSION_REVISION[ \t]+([0-9]+).*" "\\1" Xerces_PATCH "${_contents}") + + if(NOT ${Xerces_MAJOR} MATCHES "^[0-9]+$") + message(FATAL_ERROR "Version parsing failed for XERCES_VERSION_MAJOR!") + endif() + if(NOT ${Xerces_MINOR} MATCHES "^[0-9]+$") + message(FATAL_ERROR "Version parsing failed for XERCES_VERSION_MINOR!") + endif() + if(NOT ${Xerces_PATCH} MATCHES "^[0-9]+$") + message(FATAL_ERROR "Version parsing failed for XERCES_VERSION_REVISION!") + endif() + + set(Xerces_VERSION "${Xerces_MAJOR}.${Xerces_MINOR}.${Xerces_PATCH}" PARENT_SCOPE) + else() + message(FATAL_ERROR "Include file ${version_hdr} does not exist or does not contain expected version information") + endif() +endfunction(_Xerces_GET_VERSION) + +# Find include directory +find_path(Xerces_INCLUDE_DIR + NAMES "xercesc/util/PlatformUtils.hpp" + DOC "Xerces-C++ include directory") +mark_as_advanced(Xerces_INCLUDE_DIR) + +# Find all Xerces libraries +find_library(Xerces_LIBRARY "xerces-c" + DOC "Xerces-C++ libraries") +mark_as_advanced(Xerces_LIBRARY) + +if(Xerces_INCLUDE_DIR) + _Xerces_GET_VERSION("${Xerces_INCLUDE_DIR}/xercesc/util/XercesVersion.hpp") +endif(Xerces_INCLUDE_DIR) + +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