1 # Distributed under the OSI-approved BSD 3-Clause License. See accompanying 2 # file Copyright.txt or https://cmake.org/licensing for details. 4 # XXX: Copied from CMake, but includes vtkDetectLibraryType and the ICU dependency. 5 # See https://gitlab.kitware.com/cmake/cmake/-/issues/18564 7 #[=======================================================================[.rst: 11 Find the XML processing library (libxml2).
16 This module defines :prop_tgt:`IMPORTED`
target ``LibXml2::LibXml2``,
if 17 libxml2 has been found.
22 This module will
set the following variables in your project:
25 true if libxml2 headers and libraries were found
26 ``LIBXML2_INCLUDE_DIR``
27 the directory containing LibXml2 headers
28 ``LIBXML2_INCLUDE_DIRS``
29 list of the include directories needed to use LibXml2
31 LibXml2 libraries to be linked
32 ``LIBXML2_DEFINITIONS``
33 the compiler switches required
for using LibXml2
34 ``LIBXML2_XMLLINT_EXECUTABLE``
35 path to the XML checking tool xmllint coming with LibXml2
36 ``LIBXML2_VERSION_STRING``
37 the
version of LibXml2 found (since CMake 2.8.8)
42 The following cache variables may also be
set:
44 ``LIBXML2_INCLUDE_DIR``
45 the directory containing LibXml2 headers
47 path to the LibXml2 library
48 #]=======================================================================] 50 # use pkg-config to get the directories and then use these values 51 # in the find_path() and find_library() calls 52 find_package(PkgConfig QUIET)
53 PKG_CHECK_MODULES(PC_LIBXML QUIET libxml-2.0)
54 set(LIBXML2_DEFINITIONS ${PC_LIBXML_CFLAGS_OTHER})
56 find_path(LIBXML2_INCLUDE_DIR NAMES libxml/xpath.h
58 ${PC_LIBXML_INCLUDEDIR}
59 ${PC_LIBXML_INCLUDE_DIRS}
63 # CMake 3.9 and below used
'LIBXML2_LIBRARIES' as the name of
64 # the cache entry storing the find_library result. Use the
65 # value
if it was
set by the project or user.
66 if(DEFINED LIBXML2_LIBRARIES AND NOT DEFINED LIBXML2_LIBRARY)
67 set(LIBXML2_LIBRARY ${LIBXML2_LIBRARIES})
70 find_library(LIBXML2_LIBRARY NAMES xml2 libxml2
73 ${PC_LIBXML_LIBRARY_DIRS}
76 find_program(LIBXML2_XMLLINT_EXECUTABLE xmllint)
77 # for backwards compat. with KDE 4.0.x: 78 set(XMLLINT_EXECUTABLE
"${LIBXML2_XMLLINT_EXECUTABLE}")
81 set(LIBXML2_VERSION_STRING ${PC_LIBXML_VERSION})
82 elseif(LIBXML2_INCLUDE_DIR AND EXISTS
"${LIBXML2_INCLUDE_DIR}/libxml/xmlversion.h")
83 file(STRINGS
"${LIBXML2_INCLUDE_DIR}/libxml/xmlversion.h" libxml2_version_str
84 REGEX
"^#define[\t ]+LIBXML_DOTTED_VERSION[\t ]+\".*\"")
86 string(REGEX REPLACE
"^#define[\t ]+LIBXML_DOTTED_VERSION[\t ]+\"([^\"]*)\".*" "\\1" 87 LIBXML2_VERSION_STRING
"${libxml2_version_str}")
88 unset(libxml2_version_str)
91 set(LIBXML2_INCLUDE_DIRS ${LIBXML2_INCLUDE_DIR} ${PC_LIBXML_INCLUDE_DIRS})
92 set(LIBXML2_LIBRARIES ${LIBXML2_LIBRARY})
94 include(FindPackageHandleStandardArgs)
95 FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibXml2
96 REQUIRED_VARS LIBXML2_LIBRARY LIBXML2_INCLUDE_DIR
97 VERSION_VAR LIBXML2_VERSION_STRING)
99 mark_as_advanced(LIBXML2_INCLUDE_DIR LIBXML2_LIBRARY LIBXML2_XMLLINT_EXECUTABLE)
101 if(LibXml2_FOUND AND NOT TARGET LibXml2::LibXml2)
102 include(vtkDetectLibraryType)
104 PATH
"${LIBXML2_LIBRARY}")
105 add_library(LibXml2::LibXml2
"${libxml2_library_type}" IMPORTED)
106 unset(libxml2_library_type)
107 set_target_properties(LibXml2::LibXml2
109 IMPORTED_LOCATION
"${LIBXML2_LIBRARY}" 110 IMPORTED_IMPLIB
"${LIBXML2_LIBRARY}" 111 INTERFACE_INCLUDE_DIRECTORIES
"${LIBXML2_INCLUDE_DIRS}")
113 find_package(ICU QUIET COMPONENTS uc)
115 set_target_properties(LibXml2::LibXml2
117 IMPORTED_LINK_INTERFACE_LIBRARIES
"ICU::uc")
boost::graph_traits< vtkGraph *>::vertex_descriptor target(boost::graph_traits< vtkGraph *>::edge_descriptor e, vtkGraph *)
function vtk_detect_library_type(output)
Detect library type of a library.