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