1 | # libxml2-config.cmake
|
---|
2 | # --------------------
|
---|
3 | #
|
---|
4 | # Libxml2 cmake module.
|
---|
5 | # This module sets the following variables:
|
---|
6 | #
|
---|
7 | # ::
|
---|
8 | #
|
---|
9 | # LIBXML2_INCLUDE_DIR - Directory where LibXml2 headers are located.
|
---|
10 | # LIBXML2_INCLUDE_DIRS - list of the include directories needed to use LibXml2.
|
---|
11 | # LIBXML2_LIBRARY - path to the LibXml2 library.
|
---|
12 | # LIBXML2_LIBRARIES - xml2 libraries to link against.
|
---|
13 | # LIBXML2_DEFINITIONS - the compiler switches required for using LibXml2.
|
---|
14 | # LIBXML2_VERSION_MAJOR - The major version of libxml2.
|
---|
15 | # LIBXML2_VERSION_MINOR - The minor version of libxml2.
|
---|
16 | # LIBXML2_VERSION_PATCH - The patch version of libxml2.
|
---|
17 | # LIBXML2_VERSION_STRING - version number as a string (ex: "2.3.4")
|
---|
18 | # LIBXML2_MODULES - whether libxml2 has dso support
|
---|
19 | # LIBXML2_XMLLINT_EXECUTABLE - path to the XML checking tool xmllint coming with LibXml2
|
---|
20 | #
|
---|
21 | # The following targets are defined:
|
---|
22 | #
|
---|
23 | # LibXml2::LibXml2 - the LibXml2 library
|
---|
24 | # LibXml2::xmllint - the xmllint command-line executable
|
---|
25 |
|
---|
26 | get_filename_component(_libxml2_rootdir ${CMAKE_CURRENT_LIST_DIR}/../../../ ABSOLUTE)
|
---|
27 |
|
---|
28 | set(LIBXML2_VERSION_MAJOR @LIBXML_MAJOR_VERSION@)
|
---|
29 | set(LIBXML2_VERSION_MINOR @LIBXML_MINOR_VERSION@)
|
---|
30 | set(LIBXML2_VERSION_MICRO @LIBXML_MICRO_VERSION@)
|
---|
31 | set(LIBXML2_VERSION_STRING "@VERSION@")
|
---|
32 | set(LIBXML2_DEFINITIONS "@XML_CFLAGS@")
|
---|
33 | set(LIBXML2_INSTALL_PREFIX ${_libxml2_rootdir})
|
---|
34 | set(LIBXML2_INCLUDE_DIR ${_libxml2_rootdir}/include/libxml2)
|
---|
35 | set(LIBXML2_LIBRARY_DIR ${_libxml2_rootdir}/lib)
|
---|
36 |
|
---|
37 | find_library(LIBXML2_LIBRARY NAMES xml2 HINTS ${LIBXML2_LIBRARY_DIR} NO_DEFAULT_PATH)
|
---|
38 | find_program(LIBXML2_XMLCATALOG_EXECUTABLE NAMES xmlcatalog HINTS ${_libxml2_rootdir}/bin NO_DEFAULT_PATH)
|
---|
39 | find_program(LIBXML2_XMLLINT_EXECUTABLE NAMES xmllint HINTS ${_libxml2_rootdir}/bin NO_DEFAULT_PATH)
|
---|
40 |
|
---|
41 | set(LIBXML2_LIBRARIES ${LIBXML2_LIBRARY})
|
---|
42 | set(LIBXML2_INCLUDE_DIRS ${LIBXML2_INCLUDE_DIR})
|
---|
43 | unset(LIBXML2_INTERFACE_LINK_LIBRARIES)
|
---|
44 |
|
---|
45 | include(CMakeFindDependencyMacro)
|
---|
46 |
|
---|
47 | set(LIBXML2_WITH_ICONV @WITH_ICONV@)
|
---|
48 | set(LIBXML2_WITH_THREADS @WITH_THREADS@)
|
---|
49 | set(LIBXML2_WITH_ICU @WITH_ICU@)
|
---|
50 | set(LIBXML2_WITH_LZMA @WITH_LZMA@)
|
---|
51 | set(LIBXML2_WITH_ZLIB @WITH_ZLIB@)
|
---|
52 |
|
---|
53 | if(LIBXML2_WITH_ICONV)
|
---|
54 | find_dependency(Iconv)
|
---|
55 | list(APPEND LIBXML2_LIBRARIES ${Iconv_LIBRARIES})
|
---|
56 | list(APPEND LIBXML2_INCLUDE_DIRS ${Iconv_INCLUDE_DIRS})
|
---|
57 | list(APPEND LIBXML2_INTERFACE_LINK_LIBRARIES "Iconv::Iconv")
|
---|
58 | endif()
|
---|
59 |
|
---|
60 | if(LIBXML2_WITH_THREADS)
|
---|
61 | find_dependency(Threads)
|
---|
62 | list(APPEND LIBXML2_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
|
---|
63 | list(APPEND LIBXML2_INTERFACE_LINK_LIBRARIES "\$<LINK_ONLY:Threads::Threads>")
|
---|
64 | endif()
|
---|
65 |
|
---|
66 | if(LIBXML2_WITH_ICU)
|
---|
67 | find_dependency(ICU COMPONENTS data i18n uc)
|
---|
68 | list(APPEND LIBXML2_LIBRARIES ${ICU_LIBRARIES})
|
---|
69 | list(APPEND LIBXML2_INTERFACE_LINK_LIBRARIES "\$<LINK_ONLY:ICU::data>;\$<LINK_ONLY:ICU::i18n>;\$<LINK_ONLY:ICU::uc>")
|
---|
70 | endif()
|
---|
71 |
|
---|
72 | if(LIBXML2_WITH_LZMA)
|
---|
73 | find_dependency(LibLZMA)
|
---|
74 | list(APPEND LIBXML2_LIBRARIES ${LIBLZMA_LIBRARIES})
|
---|
75 | list(APPEND LIBXML2_INTERFACE_LINK_LIBRARIES "\$<LINK_ONLY:LibLZMA::LibLZMA>")
|
---|
76 | endif()
|
---|
77 |
|
---|
78 | if(LIBXML2_WITH_ZLIB)
|
---|
79 | find_dependency(ZLIB)
|
---|
80 | list(APPEND LIBXML2_LIBRARIES ${ZLIB_LIBRARIES})
|
---|
81 | list(APPEND LIBXML2_INTERFACE_LINK_LIBRARIES "\$<LINK_ONLY:ZLIB::ZLIB>")
|
---|
82 | endif()
|
---|
83 |
|
---|
84 | if(UNIX)
|
---|
85 | list(APPEND LIBXML2_LIBRARIES m)
|
---|
86 | list(APPEND LIBXML2_INTERFACE_LINK_LIBRARIES "\$<LINK_ONLY:m>")
|
---|
87 | endif()
|
---|
88 |
|
---|
89 | if(WIN32)
|
---|
90 | list(APPEND LIBXML2_LIBRARIES ws2_32)
|
---|
91 | list(APPEND LIBXML2_INTERFACE_LINK_LIBRARIES "\$<LINK_ONLY:ws2_32>")
|
---|
92 | endif()
|
---|
93 |
|
---|
94 | # whether libxml2 has dso support
|
---|
95 | set(LIBXML2_MODULES @WITH_MODULES@)
|
---|
96 |
|
---|
97 | mark_as_advanced(LIBXML2_LIBRARY LIBXML2_XMLCATALOG_EXECUTABLE LIBXML2_XMLLINT_EXECUTABLE)
|
---|
98 |
|
---|
99 | if(NOT TARGET LibXml2::LibXml2 AND DEFINED LIBXML2_LIBRARY AND DEFINED LIBXML2_INCLUDE_DIRS)
|
---|
100 | add_library(LibXml2::LibXml2 UNKNOWN IMPORTED)
|
---|
101 | set_target_properties(LibXml2::LibXml2 PROPERTIES IMPORTED_LOCATION "${LIBXML2_LIBRARY}")
|
---|
102 | set_target_properties(LibXml2::LibXml2 PROPERTIES INTERFACE_COMPILE_OPTIONS "${LIBXML2_DEFINITIONS}")
|
---|
103 | set_target_properties(LibXml2::LibXml2 PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${LIBXML2_INCLUDE_DIRS}")
|
---|
104 | set_target_properties(LibXml2::LibXml2 PROPERTIES INTERFACE_LINK_LIBRARIES "${LIBXML2_INTERFACE_LINK_LIBRARIES}")
|
---|
105 | endif()
|
---|
106 |
|
---|
107 | if(NOT TARGET LibXml2::xmlcatalog AND DEFINED LIBXML2_XMLCATALOG_EXECUTABLE)
|
---|
108 | add_executable(LibXml2::xmlcatalog IMPORTED)
|
---|
109 | set_target_properties(LibXml2::xmlcatalog PROPERTIES IMPORTED_LOCATION "${LIBXML2_XMLCATALOG_EXECUTABLE}")
|
---|
110 | endif()
|
---|
111 |
|
---|
112 | if(NOT TARGET LibXml2::xmllint AND DEFINED LIBXML2_XMLLINT_EXECUTABLE)
|
---|
113 | add_executable(LibXml2::xmllint IMPORTED)
|
---|
114 | set_target_properties(LibXml2::xmllint PROPERTIES IMPORTED_LOCATION "${LIBXML2_XMLLINT_EXECUTABLE}")
|
---|
115 | endif()
|
---|