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