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 | if(NOT Iconv_FOUND)
|
---|
59 | set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)
|
---|
60 | set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "Iconv dependency was not found")
|
---|
61 | return()
|
---|
62 | endif()
|
---|
63 | endif()
|
---|
64 |
|
---|
65 | if(LIBXML2_WITH_THREADS)
|
---|
66 | find_dependency(Threads)
|
---|
67 | list(APPEND LIBXML2_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
|
---|
68 | list(APPEND LIBXML2_INTERFACE_LINK_LIBRARIES "\$<LINK_ONLY:Threads::Threads>")
|
---|
69 | if(NOT Threads_FOUND)
|
---|
70 | set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)
|
---|
71 | set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "Threads dependency was not found")
|
---|
72 | return()
|
---|
73 | endif()
|
---|
74 | endif()
|
---|
75 |
|
---|
76 | if(LIBXML2_WITH_ICU)
|
---|
77 | find_dependency(ICU COMPONENTS data i18n uc)
|
---|
78 | list(APPEND LIBXML2_LIBRARIES ${ICU_LIBRARIES})
|
---|
79 | list(APPEND LIBXML2_INTERFACE_LINK_LIBRARIES "\$<LINK_ONLY:ICU::data>;\$<LINK_ONLY:ICU::i18n>;\$<LINK_ONLY:ICU::uc>")
|
---|
80 | if(NOT ICU_FOUND)
|
---|
81 | set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)
|
---|
82 | set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "ICU dependency was not found")
|
---|
83 | return()
|
---|
84 | endif()
|
---|
85 | endif()
|
---|
86 |
|
---|
87 | if(LIBXML2_WITH_LZMA)
|
---|
88 | find_dependency(LibLZMA)
|
---|
89 | list(APPEND LIBXML2_LIBRARIES ${LIBLZMA_LIBRARIES})
|
---|
90 | list(APPEND LIBXML2_INTERFACE_LINK_LIBRARIES "\$<LINK_ONLY:LibLZMA::LibLZMA>")
|
---|
91 | if(NOT LibLZMA_FOUND)
|
---|
92 | set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)
|
---|
93 | set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "LibLZMA dependency was not found")
|
---|
94 | return()
|
---|
95 | endif()
|
---|
96 | endif()
|
---|
97 |
|
---|
98 | if(LIBXML2_WITH_ZLIB)
|
---|
99 | find_dependency(ZLIB)
|
---|
100 | list(APPEND LIBXML2_LIBRARIES ${ZLIB_LIBRARIES})
|
---|
101 | list(APPEND LIBXML2_INTERFACE_LINK_LIBRARIES "\$<LINK_ONLY:ZLIB::ZLIB>")
|
---|
102 | if(NOT ZLIB_FOUND)
|
---|
103 | set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)
|
---|
104 | set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "ZLIB dependency was not found")
|
---|
105 | return()
|
---|
106 | endif()
|
---|
107 | endif()
|
---|
108 |
|
---|
109 | if(UNIX)
|
---|
110 | list(APPEND LIBXML2_LIBRARIES m)
|
---|
111 | list(APPEND LIBXML2_INTERFACE_LINK_LIBRARIES "\$<LINK_ONLY:m>")
|
---|
112 | endif()
|
---|
113 |
|
---|
114 | if(WIN32)
|
---|
115 | list(APPEND LIBXML2_LIBRARIES ws2_32)
|
---|
116 | list(APPEND LIBXML2_INTERFACE_LINK_LIBRARIES "\$<LINK_ONLY:ws2_32>")
|
---|
117 | endif()
|
---|
118 |
|
---|
119 | # whether libxml2 has dso support
|
---|
120 | set(LIBXML2_MODULES @WITH_MODULES@)
|
---|
121 |
|
---|
122 | mark_as_advanced(LIBXML2_LIBRARY LIBXML2_XMLCATALOG_EXECUTABLE LIBXML2_XMLLINT_EXECUTABLE)
|
---|
123 |
|
---|
124 | if(NOT TARGET LibXml2::LibXml2 AND DEFINED LIBXML2_LIBRARY AND DEFINED LIBXML2_INCLUDE_DIRS)
|
---|
125 | add_library(LibXml2::LibXml2 UNKNOWN IMPORTED)
|
---|
126 | set_target_properties(LibXml2::LibXml2 PROPERTIES IMPORTED_LOCATION "${LIBXML2_LIBRARY}")
|
---|
127 | set_target_properties(LibXml2::LibXml2 PROPERTIES INTERFACE_COMPILE_OPTIONS "${LIBXML2_DEFINITIONS}")
|
---|
128 | set_target_properties(LibXml2::LibXml2 PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${LIBXML2_INCLUDE_DIRS}")
|
---|
129 | set_target_properties(LibXml2::LibXml2 PROPERTIES INTERFACE_LINK_LIBRARIES "${LIBXML2_INTERFACE_LINK_LIBRARIES}")
|
---|
130 | endif()
|
---|
131 |
|
---|
132 | if(NOT TARGET LibXml2::xmlcatalog AND DEFINED LIBXML2_XMLCATALOG_EXECUTABLE)
|
---|
133 | add_executable(LibXml2::xmlcatalog IMPORTED)
|
---|
134 | set_target_properties(LibXml2::xmlcatalog PROPERTIES IMPORTED_LOCATION "${LIBXML2_XMLCATALOG_EXECUTABLE}")
|
---|
135 | endif()
|
---|
136 |
|
---|
137 | if(NOT TARGET LibXml2::xmllint AND DEFINED LIBXML2_XMLLINT_EXECUTABLE)
|
---|
138 | add_executable(LibXml2::xmllint IMPORTED)
|
---|
139 | set_target_properties(LibXml2::xmllint PROPERTIES IMPORTED_LOCATION "${LIBXML2_XMLLINT_EXECUTABLE}")
|
---|
140 | endif()
|
---|