@@ -100,92 +100,65 @@ install_pkgconfigdir = install_libdir / 'pkgconfig'
100
100
# xmlxx_dep (created in libxml++/meson.build):
101
101
# Dependencies when using the libxml++ library.
102
102
103
- # libxml2's Windows-specific Makefiles don't create pkg-config files for us, so
104
- # we may need to look for it manually on Windows
105
103
xml2_min_ver = ' 2.7.7'
106
104
xml2_req = ' >= @0@' .format(xml2_min_ver)
107
- xml2_dep = dependency (' libxml-2.0' , version : xml2_req, required : host_machine .system() != ' windows' )
108
- xml2_is_subproject = false
105
+ xml2_dep = dependency (
106
+ [' libxml-2.0' , ' LibXml2' ],
107
+ version : xml2_req,
108
+ required : host_machine .system() != ' windows'
109
+ )
109
110
110
- libxml2_lib_set = false
111
+ # Setup CMake subproject for use, if needed
111
112
if not xml2_dep.found()
112
- libxml2_lib = ' libxml2'
113
- libxml2_lib_set = true
114
- xml2_dep = cpp_compiler.find_library (libxml2_lib,
115
- has_headers : [
116
- ' libxml/globals.h' ,
117
- ' libxml/parser.h' ,
118
- ' libxml/parserInternals.h' ,
119
- ' libxml/relaxng.h' ,
120
- ' libxml/tree.h' ,
121
- ' libxml/xinclude.h' ,
122
- ' libxml/xpath.h' ,
123
- ' libxml/xpathInternals.h' ,
124
- ' libxml/xmlerror.h' ,
125
- ' libxml/xmlIO.h' ,
126
- ' libxml/xmlreader.h' ,
127
- ' libxml/xmlschemas.h' ,
128
- ],
129
- required : false )
130
- if xml2_dep.found()
131
- xml_min_ver_split = xml2_min_ver.split(' .' )
132
- xml_min_ver_int = xml_min_ver_split[0 ].to_int() * 10000 + \
133
- xml_min_ver_split[1 ].to_int() * 100 + \
134
- xml_min_ver_split[2 ].to_int()
135
-
136
- if not cpp_compiler.compiles(''' #include <libxml/tree.h>
137
- #if LIBXML_VERSION < @0@
138
- # error libxml2 versions must be @1@ or later
139
- #endif''' .format(xml_min_ver_int.to_string(), xml2_min_ver),
140
- name : ' libxml2 is @0@ or later' .format(xml2_min_ver))
141
- error (' Your libxml2 installation must be @0@ or later' .format(xml2_min_ver))
142
- endif
143
- else
144
- cmake = import (' cmake' )
145
- opt_var = cmake.subproject_options()
146
- build_shared = get_option (' default_library' ) != ' static'
147
- iconv_dep = dependency (' iconv' , required : false )
148
- icu_i18n_dep = dependency (' icu-i18n' , required : false )
149
- icu_uc_dep = dependency (' icu-uc' , required : false )
150
- lzma_dep = dependency (' liblzma' , required : false )
151
- thread_dep = dependency (' threads' , required : false )
152
- zlib_dep = dependency (' zlib' , required : false )
153
- winsock_dep = cpp_compiler.find_library (' ws2_32' , required : false )
154
- cmake_build_type = get_option (' buildtype' )
155
- if get_option (' buildtype' ) == ' debugoptimized'
156
- cmake_build_type = ' RelWithDebInfo'
157
- elif get_option (' buildtype' ) == ' minsize'
158
- cmake_build_type = ' MinSizeRel'
159
- elif get_option (' buildtype' ) == ' plain'
160
- cmake_build_type = ''
161
- endif
162
- opt_var.add_cmake_defines({' BUILD_SHARED_LIBS' : build_shared,
163
- ' CMAKE_BUILD_TYPE' : cmake_build_type,
164
- ' CMAKE_MSVC_RUNTIME_LIBRARY' : '' ,
165
- ' CMAKE_C_FLAGS_INIT' : '' ,
166
- ' CMAKE_C_FLAGS_DEBUG' : '' ,
167
- ' CMAKE_C_FLAGS_RELEASE' : '' ,
168
- ' CMAKE_C_FLAGS_RELWITHDEBINFO' : '' ,
169
- ' CMAKE_C_FLAGS_MINSIZEREL' : '' ,
170
- ' LIBXML2_WITH_HTTP' : host_machine .system() != ' windows' or winsock_dep.found(),
171
- ' LIBXML2_WITH_ICONV' : iconv_dep.found(),
172
- ' LIBXML2_WITH_ICU' : icu_i18n_dep.found() and icu_uc_dep.found(),
173
- ' LIBXML2_WITH_LZMA' : lzma_dep.found(),
174
- ' LIBXML2_WITH_PYTHON' : false ,
175
- ' LIBXML2_WITH_TESTS' : build_tests,
176
- ' LIBXML2_WITH_THREADS' : thread_dep.found(),
177
- ' LIBXML2_WITH_ZLIB' : zlib_dep.found(),
178
- })
179
-
180
- xml2_sp = cmake.subproject (' libxml2_cmake' , options : opt_var)
181
- xml2_dep = xml2_sp.dependency (' LibXml2' )
182
- xml2_is_subproject = true
183
-
184
- if build_tests
185
- test (' testchar' , xml2_sp.target(' testchar' ))
186
- test (' testdict' , xml2_sp.target(' testdict' ))
187
- endif
113
+ cmake = import (' cmake' )
114
+ opt_var = cmake.subproject_options()
115
+ build_shared = get_option (' default_library' ) != ' static'
116
+ iconv_dep = dependency (' iconv' , required : false )
117
+ icu_i18n_dep = dependency (' icu-i18n' , ' ICU' ,
118
+ components : ' in' ,
119
+ required : false )
120
+ icu_uc_dep = dependency (' icu-uc' , ' ICU' ,
121
+ components : ' uc' ,
122
+ required : false )
123
+ lzma_dep = dependency ([' liblzma' ,' LibLZMA' ], required : false )
124
+ thread_dep = dependency (' threads' , required : false )
125
+ zlib_dep = dependency (' zlib' , required : false )
126
+ winsock_dep = cpp_compiler.find_library (' ws2_32' , required : false )
127
+ cmake_build_type = get_option (' buildtype' )
128
+ if get_option (' buildtype' ) == ' debugoptimized'
129
+ cmake_build_type = ' RelWithDebInfo'
130
+ elif get_option (' buildtype' ) == ' minsize'
131
+ cmake_build_type = ' MinSizeRel'
132
+ elif get_option (' buildtype' ) == ' plain'
133
+ cmake_build_type = ''
188
134
endif
135
+ opt_var.add_cmake_defines({
136
+ ' BUILD_SHARED_LIBS' : build_shared,
137
+ ' CMAKE_BUILD_TYPE' : cmake_build_type,
138
+ ' CMAKE_MSVC_RUNTIME_LIBRARY' : '' ,
139
+ ' CMAKE_C_FLAGS_INIT' : '' ,
140
+ ' CMAKE_C_FLAGS_DEBUG' : '' ,
141
+ ' CMAKE_C_FLAGS_RELEASE' : '' ,
142
+ ' CMAKE_C_FLAGS_RELWITHDEBINFO' : '' ,
143
+ ' CMAKE_C_FLAGS_MINSIZEREL' : '' ,
144
+ ' LIBXML2_WITH_HTTP' : host_machine .system() != ' windows' or winsock_dep.found(),
145
+ ' LIBXML2_WITH_ICONV' : iconv_dep.found(),
146
+ ' LIBXML2_WITH_ICU' : icu_i18n_dep.found() and icu_uc_dep.found(),
147
+ ' LIBXML2_WITH_LZMA' : lzma_dep.found(),
148
+ ' LIBXML2_WITH_PYTHON' : false ,
149
+ ' LIBXML2_WITH_TESTS' : build_tests,
150
+ ' LIBXML2_WITH_THREADS' : thread_dep.found(),
151
+ ' LIBXML2_WITH_ZLIB' : zlib_dep.found(),
152
+ })
153
+ xml2_sp = cmake.subproject (' libxml2_cmake' , options : opt_var)
154
+ xml2_dep = xml2_sp.dependency (' LibXml2' )
155
+ endif
156
+
157
+ xml2_is_subproject = xml2_dep.type_name() == ' internal'
158
+
159
+ if xml2_is_subproject and build_tests
160
+ test (' testchar' , xml2_sp.target(' testchar' ))
161
+ test (' testdict' , xml2_sp.target(' testdict' ))
189
162
endif
190
163
191
164
xmlxx_requires = []
@@ -196,9 +169,10 @@ libxml2_lib_pkgconfig = ''
196
169
if xml2_dep.type_name() == ' pkgconfig'
197
170
xmlxx_requires += [' libxml-2.0' , xml2_req]
198
171
else
199
- if libxml2_lib_set
200
- libxml2_lib_pkgconfig = ' -l@0@' .format(libxml2_lib)
201
- endif
172
+ libxml2_lib_pkgconfig = xml2_dep.get_variable (
173
+ cmake : ' LIBXML2_LIBRARIES' ,
174
+ default_value : ' LibXml2.lib' ,
175
+ )
202
176
endif
203
177
204
178
xmlxx_requires = ' ' .join(xmlxx_requires)
0 commit comments