2016-09-27 22:01:08 +03:00
|
|
|
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
|
|
# file Copyright.txt or https://cmake.org/licensing for details.
|
|
|
|
|
2014-08-17 15:58:16 +04:00
|
|
|
#.rst:
|
2014-12-04 18:36:21 +03:00
|
|
|
# FindXercesC
|
|
|
|
# -----------
|
2014-08-17 15:58:16 +04:00
|
|
|
#
|
|
|
|
# Find the Apache Xerces-C++ validating XML parser headers and libraries.
|
|
|
|
#
|
2015-11-18 19:45:54 +03:00
|
|
|
# Imported targets
|
|
|
|
# ^^^^^^^^^^^^^^^^
|
2014-08-17 15:58:16 +04:00
|
|
|
#
|
2015-11-18 19:45:54 +03:00
|
|
|
# This module defines the following :prop_tgt:`IMPORTED` targets:
|
2014-08-17 15:58:16 +04:00
|
|
|
#
|
2015-11-18 19:45:54 +03:00
|
|
|
# ``XercesC::XercesC``
|
|
|
|
# The Xerces-C++ ``xerces-c`` library, if found.
|
2014-08-17 15:58:16 +04:00
|
|
|
#
|
2015-11-18 19:45:54 +03:00
|
|
|
# Result variables
|
|
|
|
# ^^^^^^^^^^^^^^^^
|
|
|
|
#
|
|
|
|
# This module will set the following variables in your project:
|
|
|
|
#
|
|
|
|
# ``XercesC_FOUND``
|
|
|
|
# true if the Xerces headers and libraries were found
|
|
|
|
# ``XercesC_VERSION``
|
|
|
|
# Xerces release version
|
|
|
|
# ``XercesC_INCLUDE_DIRS``
|
|
|
|
# the directory containing the Xerces headers
|
|
|
|
# ``XercesC_LIBRARIES``
|
|
|
|
# Xerces libraries to be linked
|
|
|
|
#
|
|
|
|
# Cache variables
|
|
|
|
# ^^^^^^^^^^^^^^^
|
|
|
|
#
|
|
|
|
# The following cache variables may also be set:
|
|
|
|
#
|
|
|
|
# ``XercesC_INCLUDE_DIR``
|
|
|
|
# the directory containing the Xerces headers
|
|
|
|
# ``XercesC_LIBRARY``
|
|
|
|
# the Xerces library
|
2014-08-17 15:58:16 +04:00
|
|
|
|
|
|
|
# Written by Roger Leigh <rleigh@codelibre.net>
|
|
|
|
|
2014-12-04 18:36:21 +03:00
|
|
|
function(_XercesC_GET_VERSION version_hdr)
|
2014-08-17 15:58:16 +04:00
|
|
|
file(STRINGS ${version_hdr} _contents REGEX "^[ \t]*#define XERCES_VERSION_.*")
|
|
|
|
if(_contents)
|
2014-12-04 18:36:21 +03:00
|
|
|
string(REGEX REPLACE ".*#define XERCES_VERSION_MAJOR[ \t]+([0-9]+).*" "\\1" XercesC_MAJOR "${_contents}")
|
|
|
|
string(REGEX REPLACE ".*#define XERCES_VERSION_MINOR[ \t]+([0-9]+).*" "\\1" XercesC_MINOR "${_contents}")
|
|
|
|
string(REGEX REPLACE ".*#define XERCES_VERSION_REVISION[ \t]+([0-9]+).*" "\\1" XercesC_PATCH "${_contents}")
|
2014-08-17 15:58:16 +04:00
|
|
|
|
2014-12-04 18:36:21 +03:00
|
|
|
if(NOT XercesC_MAJOR MATCHES "^[0-9]+$")
|
2014-08-17 15:58:16 +04:00
|
|
|
message(FATAL_ERROR "Version parsing failed for XERCES_VERSION_MAJOR!")
|
|
|
|
endif()
|
2014-12-04 18:36:21 +03:00
|
|
|
if(NOT XercesC_MINOR MATCHES "^[0-9]+$")
|
2014-08-17 15:58:16 +04:00
|
|
|
message(FATAL_ERROR "Version parsing failed for XERCES_VERSION_MINOR!")
|
|
|
|
endif()
|
2014-12-04 18:36:21 +03:00
|
|
|
if(NOT XercesC_PATCH MATCHES "^[0-9]+$")
|
2014-08-17 15:58:16 +04:00
|
|
|
message(FATAL_ERROR "Version parsing failed for XERCES_VERSION_REVISION!")
|
|
|
|
endif()
|
|
|
|
|
2014-12-04 18:36:21 +03:00
|
|
|
set(XercesC_VERSION "${XercesC_MAJOR}.${XercesC_MINOR}.${XercesC_PATCH}" PARENT_SCOPE)
|
2014-08-17 15:58:16 +04:00
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "Include file ${version_hdr} does not exist or does not contain expected version information")
|
|
|
|
endif()
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
# Find include directory
|
2014-12-04 18:36:21 +03:00
|
|
|
find_path(XercesC_INCLUDE_DIR
|
2014-08-17 15:58:16 +04:00
|
|
|
NAMES "xercesc/util/PlatformUtils.hpp"
|
|
|
|
DOC "Xerces-C++ include directory")
|
2014-12-04 18:36:21 +03:00
|
|
|
mark_as_advanced(XercesC_INCLUDE_DIR)
|
2014-08-17 15:58:16 +04:00
|
|
|
|
2015-08-07 16:54:34 +03:00
|
|
|
if(NOT XercesC_LIBRARY)
|
|
|
|
# Find all XercesC libraries
|
|
|
|
find_library(XercesC_LIBRARY_RELEASE
|
|
|
|
NAMES "xerces-c" "xerces-c_3"
|
|
|
|
DOC "Xerces-C++ libraries (release)")
|
|
|
|
find_library(XercesC_LIBRARY_DEBUG
|
2015-08-13 18:37:41 +03:00
|
|
|
NAMES "xerces-cd" "xerces-c_3D" "xerces-c_3_1D"
|
2015-08-07 16:54:34 +03:00
|
|
|
DOC "Xerces-C++ libraries (debug)")
|
|
|
|
include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake)
|
|
|
|
select_library_configurations(XercesC)
|
|
|
|
mark_as_advanced(XercesC_LIBRARY_RELEASE XercesC_LIBRARY_DEBUG)
|
|
|
|
endif()
|
2014-08-17 15:58:16 +04:00
|
|
|
|
2014-12-04 18:36:21 +03:00
|
|
|
if(XercesC_INCLUDE_DIR)
|
|
|
|
_XercesC_GET_VERSION("${XercesC_INCLUDE_DIR}/xercesc/util/XercesVersion.hpp")
|
2014-08-17 15:58:16 +04:00
|
|
|
endif()
|
|
|
|
|
2014-10-03 01:44:39 +04:00
|
|
|
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
|
2014-12-04 18:36:21 +03:00
|
|
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(XercesC
|
|
|
|
FOUND_VAR XercesC_FOUND
|
|
|
|
REQUIRED_VARS XercesC_LIBRARY
|
|
|
|
XercesC_INCLUDE_DIR
|
|
|
|
XercesC_VERSION
|
|
|
|
VERSION_VAR XercesC_VERSION
|
|
|
|
FAIL_MESSAGE "Failed to find XercesC")
|
2014-08-17 15:58:16 +04:00
|
|
|
|
2014-12-04 18:36:21 +03:00
|
|
|
if(XercesC_FOUND)
|
|
|
|
set(XercesC_INCLUDE_DIRS "${XercesC_INCLUDE_DIR}")
|
|
|
|
set(XercesC_LIBRARIES "${XercesC_LIBRARY}")
|
2015-11-18 19:45:54 +03:00
|
|
|
|
|
|
|
# For header-only libraries
|
|
|
|
if(NOT TARGET XercesC::XercesC)
|
|
|
|
add_library(XercesC::XercesC UNKNOWN IMPORTED)
|
|
|
|
if(XercesC_INCLUDE_DIRS)
|
|
|
|
set_target_properties(XercesC::XercesC PROPERTIES
|
|
|
|
INTERFACE_INCLUDE_DIRECTORIES "${XercesC_INCLUDE_DIRS}")
|
|
|
|
endif()
|
|
|
|
if(EXISTS "${XercesC_LIBRARY}")
|
|
|
|
set_target_properties(XercesC::XercesC PROPERTIES
|
|
|
|
IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
|
|
|
|
IMPORTED_LOCATION "${XercesC_LIBRARY}")
|
|
|
|
endif()
|
|
|
|
if(EXISTS "${XercesC_LIBRARY_RELEASE}")
|
|
|
|
set_property(TARGET XercesC::XercesC APPEND PROPERTY
|
|
|
|
IMPORTED_CONFIGURATIONS RELEASE)
|
|
|
|
set_target_properties(XercesC::XercesC PROPERTIES
|
|
|
|
IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "CXX"
|
|
|
|
IMPORTED_LOCATION_RELEASE "${XercesC_LIBRARY_RELEASE}")
|
|
|
|
endif()
|
2016-08-03 18:12:01 +03:00
|
|
|
if(EXISTS "${XercesC_LIBRARY_DEBUG}")
|
|
|
|
set_property(TARGET XercesC::XercesC APPEND PROPERTY
|
|
|
|
IMPORTED_CONFIGURATIONS DEBUG)
|
|
|
|
set_target_properties(XercesC::XercesC PROPERTIES
|
|
|
|
IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "CXX"
|
|
|
|
IMPORTED_LOCATION_DEBUG "${XercesC_LIBRARY_DEBUG}")
|
|
|
|
endif()
|
2015-11-18 19:45:54 +03:00
|
|
|
endif()
|
2014-08-17 15:58:16 +04:00
|
|
|
endif()
|