1 project('harfbuzz', 'c', 'cpp',
2 meson_version: '>= 0.55.0',
5 'cpp_rtti=false', # Just to support msvc, we are passing -fno-exceptions also anyway
7 'wrap_mode=nofallback', # Use --wrap-mode=default to revert, https://github.com/harfbuzz/harfbuzz/pull/2548
11 hb_version_arr = meson.project_version().split('.')
12 hb_version_major = hb_version_arr[0].to_int()
13 hb_version_minor = hb_version_arr[1].to_int()
14 hb_version_micro = hb_version_arr[2].to_int()
17 hb_version_int = hb_version_major*10000 + hb_version_minor*100 + hb_version_micro
18 hb_libtool_version_info = '@0@:0:@0@'.format(hb_version_int)
20 pkgmod = import('pkgconfig')
21 cpp = meson.get_compiler('cpp')
22 null_dep = dependency('', required: false)
24 if cpp.get_id() == 'msvc'
25 # Ignore several spurious warnings for things HarfBuzz does very commonly.
26 # If a warning is completely useless and spammy, use '/wdXXXX' to suppress it
27 # If a warning is harmless but hard to fix, use '/woXXXX' so it's shown once
28 # NOTE: Only add warnings here if you are sure they're spurious
30 '/wd4018', # implicit signed/unsigned conversion
31 '/wd4146', # unary minus on unsigned (beware INT_MIN)
32 '/wd4244', # lossy type conversion (e.g. double -> int)
33 '/wd4305', # truncating type conversion (e.g. double -> float)
34 cpp.get_supported_arguments(['/utf-8']), # set the input encoding to utf-8
36 add_project_arguments(msvc_args, language: ['c', 'cpp'])
37 # Disable SAFESEH with MSVC for libs that use external deps that are built with MinGW
38 # noseh_link_args = ['/SAFESEH:NO']
39 # disable exception handling
40 add_project_arguments(['/EHs-', '/EHc-'], language: 'cpp')
43 add_project_link_arguments(cpp.get_supported_link_arguments([
44 '-Bsymbolic-functions'
47 add_project_arguments(cpp.get_supported_arguments([
50 '-fno-threadsafe-statics',
51 '-fvisibility-inlines-hidden',
54 if host_machine.cpu_family() == 'arm' and cpp.alignment('struct { char c; }') != 1
55 if cpp.has_argument('-mstructure-size-boundary=8')
56 add_project_arguments('-mstructure-size-boundary=8', language: 'cpp')
60 if host_machine.system() == 'windows'
61 add_project_arguments(cpp.get_supported_arguments([
84 m_dep = cpp.find_library('m', required: false)
86 freetype_dep = null_dep
87 if not get_option('freetype').disabled()
88 freetype_dep = dependency('freetype2', required: false)
90 if (not freetype_dep.found() and
91 cpp.get_id() == 'msvc' and
92 cpp.has_header('ft2build.h'))
93 freetype_dep = cpp.find_library('freetype', required: false)
96 if not freetype_dep.found()
97 # https://github.com/harfbuzz/harfbuzz/pull/2498
98 freetype_dep = dependency('freetype2', required: get_option('freetype'),
99 default_options: ['harfbuzz=disabled'])
103 glib_dep = dependency('glib-2.0', required: get_option('glib'))
104 gobject_dep = dependency('gobject-2.0', required: get_option('gobject'))
105 graphite2_dep = dependency('graphite2', required: get_option('graphite2'))
106 graphite_dep = dependency('graphite2', required: get_option('graphite'))
109 if not get_option('icu').disabled()
110 icu_dep = dependency('icu-uc', required: false)
112 if (not icu_dep.found() and
113 cpp.get_id() == 'msvc' and
114 cpp.has_header('unicode/uchar.h') and
115 cpp.has_header('unicode/unorm2.h') and
116 cpp.has_header('unicode/ustring.h') and
117 cpp.has_header('unicode/utf16.h') and
118 cpp.has_header('unicode/uversion.h') and
119 cpp.has_header('unicode/uscript.h'))
120 if get_option('buildtype') == 'debug'
121 icu_dep = cpp.find_library('icuucd', required: false)
123 icu_dep = cpp.find_library('icuuc', required: false)
127 if not icu_dep.found()
128 icu_dep = dependency('icu-uc', required: get_option('icu'))
132 if icu_dep.found() and icu_dep.type_name() == 'pkgconfig'
133 icu_defs = icu_dep.get_variable(pkgconfig: 'DEFS', default_value: '')
135 add_project_arguments(icu_defs, language: ['c', 'cpp'])
140 cairo_ft_dep = null_dep
141 if not get_option('cairo').disabled()
142 cairo_dep = dependency('cairo', required: false)
143 cairo_ft_dep = dependency('cairo-ft', required: false)
145 if (not cairo_dep.found() and
146 cpp.get_id() == 'msvc' and
147 cpp.has_header('cairo.h'))
148 cairo_dep = cpp.find_library('cairo', required: false)
149 if cairo_dep.found() and cpp.has_function('cairo_ft_font_face_create_for_ft_face',
150 prefix: '#include <cairo-ft.h>',
151 dependencies: cairo_dep)
152 cairo_ft_dep = cairo_dep
156 if not cairo_dep.found()
157 # Note that we don't have harfbuzz -> cairo -> freetype2 -> harfbuzz fallback
158 # dependency cycle here because we have configured freetype2 above with
159 # harfbuzz support disabled, so when cairo will lookup freetype2 dependency
160 # it will be forced to use that one.
161 cairo_dep = dependency('cairo', required: get_option('cairo'))
162 cairo_ft_dep = dependency('cairo-ft', required: get_option('cairo'))
166 chafa_dep = dependency('chafa', version: '>= 1.6.0', required: get_option('chafa'))
168 conf = configuration_data()
169 incconfig = include_directories('.')
171 add_project_arguments('-DHAVE_CONFIG_H', language: ['c', 'cpp'])
174 '-Wno-non-virtual-dtor',
177 cpp_args = cpp.get_supported_arguments(warn_cflags)
180 conf.set('HAVE_GLIB', 1)
183 if gobject_dep.found()
184 conf.set('HAVE_GOBJECT', 1)
188 conf.set('HAVE_CAIRO', 1)
191 if cairo_ft_dep.found()
192 conf.set('HAVE_CAIRO_FT', 1)
196 conf.set('HAVE_CHAFA', 1)
199 if graphite2_dep.found() or graphite_dep.found()
200 conf.set('HAVE_GRAPHITE2', 1)
204 conf.set('HAVE_ICU', 1)
207 if get_option('icu_builtin')
208 conf.set('HAVE_ICU_BUILTIN', 1)
211 if get_option('experimental_api')
212 conf.set('HB_EXPERIMENTAL_API', 1)
215 if freetype_dep.found()
216 conf.set('HAVE_FREETYPE', 1)
217 check_freetype_funcs = [
218 ['FT_Get_Var_Blend_Coordinates', {'deps': freetype_dep}],
219 ['FT_Set_Var_Blend_Coordinates', {'deps': freetype_dep}],
220 ['FT_Done_MM_Var', {'deps': freetype_dep}],
223 if freetype_dep.type_name() == 'internal'
224 foreach func: check_freetype_funcs
226 conf.set('HAVE_@0@'.format(name.to_upper()), 1)
229 check_funcs += check_freetype_funcs
233 gdi_uniscribe_deps = []
234 # GDI (Uniscribe) (Windows)
235 if host_machine.system() == 'windows' and not get_option('gdi').disabled()
236 if (get_option('directwrite').enabled() and
237 not (cpp.has_header('usp10.h') and cpp.has_header('windows.h')))
238 error('GDI/Uniscribe was enabled explicitly, but required headers are missing.')
241 gdi_deps_found = true
242 foreach usplib : ['usp10', 'gdi32', 'rpcrt4']
243 dep = cpp.find_library(usplib, required: get_option('gdi'))
244 gdi_deps_found = gdi_deps_found and dep.found()
245 gdi_uniscribe_deps += dep
249 conf.set('HAVE_UNISCRIBE', 1)
250 conf.set('HAVE_GDI', 1)
254 # DirectWrite (Windows)
255 directwrite_dep = null_dep
256 if host_machine.system() == 'windows' and not get_option('directwrite').disabled()
257 if get_option('directwrite').enabled() and not cpp.has_header('dwrite_1.h')
258 error('DirectWrite was enabled explicitly, but required header is missing.')
261 directwrite_dep = cpp.find_library('dwrite', required: get_option('directwrite'))
263 if directwrite_dep.found()
264 conf.set('HAVE_DIRECTWRITE', 1)
270 if host_machine.system() == 'darwin' and not get_option('coretext').disabled()
271 app_services_dep = dependency('appleframeworks', modules: ['ApplicationServices'], required: false)
272 if cpp.has_type('CTFontRef', prefix: '#include <ApplicationServices/ApplicationServices.h>', dependencies: app_services_dep)
273 coretext_deps += [app_services_dep]
274 conf.set('HAVE_CORETEXT', 1)
275 # On iOS CoreText and CoreGraphics are stand-alone frameworks
276 # Check for a different symbol to avoid getting cached result
278 coretext_dep = dependency('appleframeworks', modules: ['CoreText'], required: false)
279 coregraphics_dep = dependency('appleframeworks', modules: ['CoreGraphics'], required: false)
280 corefoundation_dep = dependency('appleframeworks', modules: ['CoreFoundation'], required: false)
281 if cpp.has_type('CTRunRef', prefix: '#include <CoreText/CoreText.h>', dependencies: [coretext_dep, coregraphics_dep, corefoundation_dep])
282 coretext_deps += [coretext_dep, coregraphics_dep, corefoundation_dep]
283 conf.set('HAVE_CORETEXT', 1)
284 elif get_option('coretext').enabled()
285 error('CoreText was enabled explicitly, but required headers or frameworks are missing.')
291 thread_dep = null_dep
292 if host_machine.system() != 'windows'
293 thread_dep = dependency('threads', required: false)
295 if thread_dep.found()
296 conf.set('HAVE_PTHREAD', 1)
300 conf.set_quoted('PACKAGE_NAME', 'HarfBuzz')
301 conf.set_quoted('PACKAGE_VERSION', meson.project_version())
303 foreach check : check_headers
306 if cpp.has_header(name)
307 conf.set('HAVE_@0@'.format(name.to_upper().underscorify()), 1)
311 harfbuzz_extra_deps = []
312 foreach check : check_funcs
314 opts = check.get(1, {})
315 link_withs = opts.get('link_with', [])
316 check_deps = opts.get('deps', [])
320 # First try without linking
321 found = cpp.has_function(name, dependencies: check_deps)
323 if not found and link_withs.length() > 0
326 foreach link_with : link_withs
327 dep = cpp.find_library(link_with, required: false)
336 found = cpp.has_function(name, dependencies: check_deps + extra_deps)
341 harfbuzz_extra_deps += extra_deps
342 conf.set('HAVE_@0@'.format(name.to_upper()), 1)
349 if not get_option('tests').disabled()
353 if not get_option('benchmark').disabled()
357 if not get_option('docs').disabled()
361 configure_file(output: 'config.h', configuration: conf)
365 {'prefix': get_option('prefix'),
366 'bindir': get_option('bindir'),
367 'libdir': get_option('libdir'),
368 'includedir': get_option('includedir'),
369 'datadir': get_option('datadir'),
371 'Unicode callbacks (you want at least one)':
373 'Glib': conf.get('HAVE_GLIB', 0) == 1,
374 'ICU': conf.get('HAVE_ICU', 0) == 1,
376 'Font callbacks (the more the merrier)':
377 {'FreeType': conf.get('HAVE_FREETYPE', 0) == 1,
379 'Dependencies used for command-line utilities':
380 {'Cairo': conf.get('HAVE_CAIRO', 0) == 1,
381 'Chafa': conf.get('HAVE_CHAFA', 0) == 1,
383 'Additional shapers':
384 {'Graphite2': conf.get('HAVE_GRAPHITE2', 0) == 1,
386 'Platform shapers (not normally needed)':
387 {'CoreText': conf.get('HAVE_CORETEXT', 0) == 1,
388 'DirectWrite': conf.get('HAVE_DIRECTWRITE', 0) == 1,
389 'GDI/Uniscribe': (conf.get('HAVE_GDI', 0) == 1) and (conf.get('HAVE_UNISCRIBE', 0) == 1),
392 {'Documentation': conf.get('HAVE_GTK_DOC', 0) == 1,
393 'GObject bindings': conf.get('HAVE_GOBJECT', 0) == 1,
394 'Introspection': conf.get('HAVE_INTROSPECTION', 0) == 1,
395 'Experimental APIs': conf.get('HB_EXPERIMENTAL_API', 0) == 1,
398 {'Tests': get_option('tests').enabled(),
399 'Benchmark': get_option('benchmark').enabled(),
402 foreach section_title, section : build_summary
403 summary(section, bool_yn: true, section: section_title)