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 | include("${CMAKE_CURRENT_LIST_DIR}/libxml2-export.cmake")
|
---|
22 |
|
---|
23 | @PACKAGE_INIT@
|
---|
24 |
|
---|
25 | set(LIBXML2_VERSION_MAJOR @LIBXML_MAJOR_VERSION@)
|
---|
26 | set(LIBXML2_VERSION_MINOR @LIBXML_MINOR_VERSION@)
|
---|
27 | set(LIBXML2_VERSION_PATCH @LIBXML_MICRO_VERSION@)
|
---|
28 | set(LIBXML2_VERSION_STRING "@VERSION@")
|
---|
29 | set(LIBXML2_INSTALL_PREFIX ${PACKAGE_PREFIX_DIR})
|
---|
30 | set(LIBXML2_INCLUDE_DIR ${PACKAGE_PREFIX_DIR}/@CMAKE_INSTALL_INCLUDEDIR@/libxml2)
|
---|
31 | set(LIBXML2_LIBRARY_DIR ${PACKAGE_PREFIX_DIR}/@CMAKE_INSTALL_LIBDIR@)
|
---|
32 |
|
---|
33 | macro(select_library_location target basename)
|
---|
34 | if(TARGET ${target})
|
---|
35 | foreach(property IN ITEMS IMPORTED_LOCATION IMPORTED_IMPLIB)
|
---|
36 | get_target_property(${basename}_${property}_DEBUG ${target} ${property}_DEBUG)
|
---|
37 | get_target_property(${basename}_${property}_MINSIZEREL ${target} ${property}_MINSIZEREL)
|
---|
38 | get_target_property(${basename}_${property}_NOCONFIG ${target} ${property}_NOCONFIG)
|
---|
39 | get_target_property(${basename}_${property}_RELEASE ${target} ${property}_RELEASE)
|
---|
40 | get_target_property(${basename}_${property}_RELWITHDEBINFO ${target} ${property}_RELWITHDEBINFO)
|
---|
41 |
|
---|
42 | if(${basename}_${property}_DEBUG AND ${basename}_${property}_RELEASE)
|
---|
43 | set(${basename}_LIBRARY debug ${${basename}_${property}_DEBUG} optimized ${${basename}_${property}_RELEASE})
|
---|
44 | elseif(${basename}_${property}_DEBUG AND ${basename}_${property}_RELWITHDEBINFO)
|
---|
45 | set(${basename}_LIBRARY debug ${${basename}_${property}_DEBUG} optimized ${${basename}_${property}_RELWITHDEBINFO})
|
---|
46 | elseif(${basename}_${property}_DEBUG AND ${basename}_${property}_MINSIZEREL)
|
---|
47 | set(${basename}_LIBRARY debug ${${basename}_${property}_DEBUG} optimized ${${basename}_${property}_MINSIZEREL})
|
---|
48 | elseif(${basename}_${property}_RELEASE)
|
---|
49 | set(${basename}_LIBRARY ${${basename}_${property}_RELEASE})
|
---|
50 | elseif(${basename}_${property}_RELWITHDEBINFO)
|
---|
51 | set(${basename}_LIBRARY ${${basename}_${property}_RELWITHDEBINFO})
|
---|
52 | elseif(${basename}_${property}_MINSIZEREL)
|
---|
53 | set(${basename}_LIBRARY ${${basename}_${property}_MINSIZEREL})
|
---|
54 | elseif(${basename}_${property}_DEBUG)
|
---|
55 | set(${basename}_LIBRARY ${${basename}_${property}_DEBUG})
|
---|
56 | elseif(${basename}_${property}_NOCONFIG)
|
---|
57 | set(${basename}_LIBRARY ${${basename}_${property}_NOCONFIG})
|
---|
58 | endif()
|
---|
59 | endforeach()
|
---|
60 | endif()
|
---|
61 | endmacro()
|
---|
62 |
|
---|
63 | macro(select_executable_location target basename)
|
---|
64 | if(TARGET ${target})
|
---|
65 | get_target_property(${basename}_IMPORTED_LOCATION_DEBUG ${target} IMPORTED_LOCATION_DEBUG)
|
---|
66 | get_target_property(${basename}_IMPORTED_LOCATION_MINSIZEREL ${target} IMPORTED_LOCATION_MINSIZEREL)
|
---|
67 | get_target_property(${basename}_IMPORTED_LOCATION_NOCONFIG ${target} IMPORTED_LOCATION_NOCONFIG)
|
---|
68 | get_target_property(${basename}_IMPORTED_LOCATION_RELEASE ${target} IMPORTED_LOCATION_RELEASE)
|
---|
69 | get_target_property(${basename}_IMPORTED_LOCATION_RELWITHDEBINFO ${target} IMPORTED_LOCATION_RELWITHDEBINFO)
|
---|
70 |
|
---|
71 | if(${basename}_IMPORTED_LOCATION_RELEASE)
|
---|
72 | set(${basename}_EXECUTABLE ${${basename}_IMPORTED_LOCATION_RELEASE})
|
---|
73 | elseif(${basename}_IMPORTED_LOCATION_RELWITHDEBINFO)
|
---|
74 | set(${basename}_EXECUTABLE ${${basename}_IMPORTED_LOCATION_RELWITHDEBINFO})
|
---|
75 | elseif(${basename}_IMPORTED_LOCATION_MINSIZEREL)
|
---|
76 | set(${basename}_EXECUTABLE ${${basename}_IMPORTED_LOCATION_MINSIZEREL})
|
---|
77 | elseif(${basename}_IMPORTED_LOCATION_DEBUG)
|
---|
78 | set(${basename}_EXECUTABLE ${${basename}_IMPORTED_LOCATION_DEBUG})
|
---|
79 | elseif(${basename}_IMPORTED_LOCATION_NOCONFIG)
|
---|
80 | set(${basename}_EXECUTABLE ${${basename}_IMPORTED_LOCATION_NOCONFIG})
|
---|
81 | endif()
|
---|
82 | endif()
|
---|
83 | endmacro()
|
---|
84 |
|
---|
85 | select_library_location(LibXml2::LibXml2 LIBXML2)
|
---|
86 | select_executable_location(LibXml2::xmlcatalog LIBXML2_XMLCATALOG)
|
---|
87 | select_executable_location(LibXml2::xmllint LIBXML2_XMLLINT)
|
---|
88 |
|
---|
89 | set(LIBXML2_LIBRARIES ${LIBXML2_LIBRARY})
|
---|
90 | set(LIBXML2_INCLUDE_DIRS ${LIBXML2_INCLUDE_DIR})
|
---|
91 |
|
---|
92 | include(CMakeFindDependencyMacro)
|
---|
93 |
|
---|
94 | set(LIBXML2_SHARED @BUILD_SHARED_LIBS@)
|
---|
95 | set(LIBXML2_WITH_ICONV @LIBXML2_WITH_ICONV@)
|
---|
96 | set(LIBXML2_WITH_THREADS @LIBXML2_WITH_THREADS@)
|
---|
97 | set(LIBXML2_WITH_ICU @LIBXML2_WITH_ICU@)
|
---|
98 | set(LIBXML2_WITH_LZMA @LIBXML2_WITH_LZMA@)
|
---|
99 | set(LIBXML2_WITH_ZLIB @LIBXML2_WITH_ZLIB@)
|
---|
100 |
|
---|
101 | if(LIBXML2_WITH_ICONV)
|
---|
102 | find_dependency(Iconv)
|
---|
103 | list(APPEND LIBXML2_LIBRARIES ${Iconv_LIBRARIES})
|
---|
104 | list(APPEND LIBXML2_INCLUDE_DIRS ${Iconv_INCLUDE_DIRS})
|
---|
105 | if(NOT Iconv_FOUND)
|
---|
106 | set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)
|
---|
107 | set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "Iconv dependency was not found")
|
---|
108 | return()
|
---|
109 | endif()
|
---|
110 | endif()
|
---|
111 |
|
---|
112 | if(NOT LIBXML2_SHARED)
|
---|
113 | set(LIBXML2_DEFINITIONS -DLIBXML_STATIC)
|
---|
114 |
|
---|
115 | if(LIBXML2_WITH_THREADS)
|
---|
116 | find_dependency(Threads)
|
---|
117 | list(APPEND LIBXML2_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
|
---|
118 | if(NOT Threads_FOUND)
|
---|
119 | set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)
|
---|
120 | set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "Threads dependency was not found")
|
---|
121 | return()
|
---|
122 | endif()
|
---|
123 | endif()
|
---|
124 |
|
---|
125 | if(LIBXML2_WITH_ICU)
|
---|
126 | find_dependency(ICU COMPONENTS data i18n uc)
|
---|
127 | list(APPEND LIBXML2_LIBRARIES ${ICU_LIBRARIES})
|
---|
128 | if(NOT ICU_FOUND)
|
---|
129 | set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)
|
---|
130 | set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "ICU dependency was not found")
|
---|
131 | return()
|
---|
132 | endif()
|
---|
133 | endif()
|
---|
134 |
|
---|
135 | if(LIBXML2_WITH_LZMA)
|
---|
136 | find_dependency(LibLZMA)
|
---|
137 | list(APPEND LIBXML2_LIBRARIES ${LIBLZMA_LIBRARIES})
|
---|
138 | if(NOT LibLZMA_FOUND)
|
---|
139 | set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)
|
---|
140 | set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "LibLZMA dependency was not found")
|
---|
141 | return()
|
---|
142 | endif()
|
---|
143 | endif()
|
---|
144 |
|
---|
145 | if(LIBXML2_WITH_ZLIB)
|
---|
146 | find_dependency(ZLIB)
|
---|
147 | list(APPEND LIBXML2_LIBRARIES ${ZLIB_LIBRARIES})
|
---|
148 | if(NOT ZLIB_FOUND)
|
---|
149 | set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)
|
---|
150 | set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "ZLIB dependency was not found")
|
---|
151 | return()
|
---|
152 | endif()
|
---|
153 | endif()
|
---|
154 |
|
---|
155 | if(UNIX)
|
---|
156 | list(APPEND LIBXML2_LIBRARIES m)
|
---|
157 | endif()
|
---|
158 |
|
---|
159 | if(WIN32)
|
---|
160 | list(APPEND LIBXML2_LIBRARIES ws2_32)
|
---|
161 | endif()
|
---|
162 | endif()
|
---|
163 |
|
---|
164 | # whether libxml2 has dso support
|
---|
165 | set(LIBXML2_MODULES @LIBXML2_WITH_MODULES@)
|
---|
166 |
|
---|
167 | mark_as_advanced(LIBXML2_LIBRARY LIBXML2_XMLCATALOG_EXECUTABLE LIBXML2_XMLLINT_EXECUTABLE)
|
---|