Mathieu Duponchelle | 920efc0 | 2018-05-17 01:28:53 +0200 | [diff] [blame] | 1 | project('harfbuzz', 'c', 'cpp', |
Mathieu Duponchelle | 07cadc9 | 2018-06-18 17:18:05 +0200 | [diff] [blame] | 2 | meson_version: '>= 0.47.0', |
Mathieu Duponchelle | 920efc0 | 2018-05-17 01:28:53 +0200 | [diff] [blame] | 3 | version: '1.7.6') |
| 4 | |
Mathieu Duponchelle | 484313f | 2018-06-05 02:15:43 +0200 | [diff] [blame] | 5 | pkgmod = import('pkgconfig') |
Mathieu Duponchelle | 920efc0 | 2018-05-17 01:28:53 +0200 | [diff] [blame] | 6 | cpp = meson.get_compiler('cpp') |
| 7 | |
Tim-Philipp Müller | 4a47f1a | 2018-12-01 11:05:27 +0000 | [diff] [blame^] | 8 | if cpp.get_id() == 'msvc' |
| 9 | # Ignore several spurious warnings for things HarfBuzz does very commonly. |
| 10 | # If a warning is completely useless and spammy, use '/wdXXXX' to suppress it |
| 11 | # If a warning is harmless but hard to fix, use '/woXXXX' so it's shown once |
| 12 | # NOTE: Only add warnings here if you are sure they're spurious |
| 13 | msvc_args = [ |
| 14 | '/wd4018', # implicit signed/unsigned conversion |
| 15 | '/wd4146', # unary minus on unsigned (beware INT_MIN) |
| 16 | '/wd4244', # lossy type conversion (e.g. double -> int) |
| 17 | '/wd4305', # truncating type conversion (e.g. double -> float) |
| 18 | cpp.get_supported_arguments(['/utf-8']), # set the input encoding to utf-8 |
| 19 | ] |
| 20 | add_project_arguments(msvc_args, language : 'c') |
| 21 | add_project_arguments(msvc_args, language : 'cpp') |
| 22 | # Disable SAFESEH with MSVC for libs that use external deps that are built with MinGW |
| 23 | # noseh_link_args = ['/SAFESEH:NO'] |
| 24 | endif |
| 25 | |
Mathieu Duponchelle | 920efc0 | 2018-05-17 01:28:53 +0200 | [diff] [blame] | 26 | python3 = import('python').find_installation('python3') |
| 27 | |
| 28 | check_headers = [ |
| 29 | ['unistd.h'], |
| 30 | ['sys/mman.h'], |
| 31 | ['xlocale.h'], |
| 32 | ['stdbool.h'], |
| 33 | ] |
| 34 | |
| 35 | check_funcs = [ |
| 36 | ['atexit'], |
| 37 | ['mprotect'], |
| 38 | ['sysconf'], |
| 39 | ['getpagesize'], |
| 40 | ['mmap'], |
| 41 | ['isatty'], |
| 42 | ['newlocale'], |
| 43 | ['strtod_l'], |
| 44 | ['round'], |
| 45 | ] |
| 46 | |
Tim-Philipp Müller | 49ba211 | 2018-11-12 15:36:27 +0000 | [diff] [blame] | 47 | freetype_dep = dependency('freetype2', required: get_option('freetype'), |
Nirbheek Chauhan | f65def4 | 2018-10-12 19:41:49 +0530 | [diff] [blame] | 48 | fallback: ['freetype2', 'freetype_dep']) |
Tim-Philipp Müller | 49ba211 | 2018-11-12 15:36:27 +0000 | [diff] [blame] | 49 | glib_dep = dependency('glib-2.0', required: get_option('glib'), |
Nirbheek Chauhan | f65def4 | 2018-10-12 19:41:49 +0530 | [diff] [blame] | 50 | fallback: ['glib', 'libglib_dep']) |
Tim-Philipp Müller | 49ba211 | 2018-11-12 15:36:27 +0000 | [diff] [blame] | 51 | gobject_dep = dependency('gobject-2.0', required: get_option('gobject'), |
Nirbheek Chauhan | f65def4 | 2018-10-12 19:41:49 +0530 | [diff] [blame] | 52 | fallback: ['glib', 'libgobject_dep']) |
Tim-Philipp Müller | 49ba211 | 2018-11-12 15:36:27 +0000 | [diff] [blame] | 53 | cairo_dep = dependency('cairo', required: get_option('cairo'), |
Nirbheek Chauhan | f65def4 | 2018-10-12 19:41:49 +0530 | [diff] [blame] | 54 | fallback: ['cairo', 'libcairo_dep']) |
Tim-Philipp Müller | 49ba211 | 2018-11-12 15:36:27 +0000 | [diff] [blame] | 55 | fontconfig_dep = dependency('fontconfig', required: get_option('fontconfig'), |
Nirbheek Chauhan | f65def4 | 2018-10-12 19:41:49 +0530 | [diff] [blame] | 56 | fallback: ['fontconfig', 'fontconfig_dep']) |
Tim-Philipp Müller | 49ba211 | 2018-11-12 15:36:27 +0000 | [diff] [blame] | 57 | graphite2_dep = dependency('graphite2', required: get_option('graphite')) |
| 58 | icu_dep = dependency('icu-uc', required: get_option('icu')) |
Mathieu Duponchelle | fce88f9 | 2018-05-17 16:20:10 +0200 | [diff] [blame] | 59 | m_dep = cpp.find_library('m', required: false) |
Mathieu Duponchelle | 920efc0 | 2018-05-17 01:28:53 +0200 | [diff] [blame] | 60 | |
Nirbheek Chauhan | f65def4 | 2018-10-12 19:41:49 +0530 | [diff] [blame] | 61 | # Ensure that cairo-ft is fetched from the same library as cairo itself |
| 62 | if cairo_dep.found() |
| 63 | if cairo_dep.type_name() == 'pkgconfig' |
Tim-Philipp Müller | 49ba211 | 2018-11-12 15:36:27 +0000 | [diff] [blame] | 64 | cairo_ft_dep = dependency('cairo-ft', required: get_option('cairo')) |
Nirbheek Chauhan | f65def4 | 2018-10-12 19:41:49 +0530 | [diff] [blame] | 65 | else |
| 66 | cairo_ft_dep = cairo_dep |
| 67 | endif |
| 68 | else |
| 69 | # Not-found dependency |
| 70 | cairo_ft_dep = dependency('', required: false) |
| 71 | endif |
| 72 | |
Mathieu Duponchelle | fce88f9 | 2018-05-17 16:20:10 +0200 | [diff] [blame] | 73 | deps = [] |
Mathieu Duponchelle | 920efc0 | 2018-05-17 01:28:53 +0200 | [diff] [blame] | 74 | |
| 75 | conf = configuration_data() |
Tim-Philipp Müller | 618584e | 2018-11-14 20:19:36 +0000 | [diff] [blame] | 76 | incconfig = include_directories('.') |
Mathieu Duponchelle | 920efc0 | 2018-05-17 01:28:53 +0200 | [diff] [blame] | 77 | cpp_args = ['-DHAVE_CONFIG_H'] |
| 78 | |
| 79 | warn_cflags = [ |
| 80 | '-Wno-non-virtual-dtor', |
| 81 | ] |
| 82 | |
| 83 | cpp_args += cpp.get_supported_arguments(warn_cflags) |
| 84 | |
Mathieu Duponchelle | fce88f9 | 2018-05-17 16:20:10 +0200 | [diff] [blame] | 85 | if m_dep.found() |
| 86 | deps += [m_dep] |
| 87 | endif |
| 88 | |
Mathieu Duponchelle | 920efc0 | 2018-05-17 01:28:53 +0200 | [diff] [blame] | 89 | if glib_dep.found() |
| 90 | conf.set('HAVE_GLIB', 1) |
| 91 | deps += [glib_dep] |
| 92 | endif |
| 93 | |
| 94 | if gobject_dep.found() |
| 95 | conf.set('HAVE_GOBJECT', 1) |
| 96 | deps += [gobject_dep] |
| 97 | endif |
| 98 | |
| 99 | if cairo_dep.found() |
| 100 | conf.set('HAVE_CAIRO', 1) |
| 101 | deps += [cairo_dep] |
| 102 | endif |
| 103 | |
| 104 | if cairo_ft_dep.found() |
| 105 | conf.set('HAVE_CAIRO_FT', 1) |
| 106 | deps += [cairo_ft_dep] |
| 107 | endif |
| 108 | |
| 109 | if graphite2_dep.found() |
| 110 | conf.set('HAVE_GRAPHITE2', 1) |
| 111 | deps += [graphite2_dep] |
| 112 | endif |
| 113 | |
| 114 | if icu_dep.found() |
| 115 | conf.set('HAVE_ICU', 1) |
| 116 | conf.set('HAVE_ICU_BUILTIN', 1) |
| 117 | deps += [icu_dep] |
| 118 | endif |
| 119 | |
| 120 | if freetype_dep.found() |
| 121 | conf.set('HAVE_FREETYPE', 1) |
| 122 | deps += [freetype_dep] |
Mathieu Duponchelle | 04bcdb9 | 2018-06-05 20:59:29 +0200 | [diff] [blame] | 123 | check_freetype_funcs = [ |
| 124 | ['FT_Get_Var_Blend_Coordinates', {'deps': freetype_dep}], |
| 125 | ['FT_Set_Var_Blend_Coordinates', {'deps': freetype_dep}], |
| 126 | ['FT_Done_MM_Var', {'deps': freetype_dep}], |
| 127 | ] |
Mathieu Duponchelle | 920efc0 | 2018-05-17 01:28:53 +0200 | [diff] [blame] | 128 | |
| 129 | if freetype_dep.type_name() == 'internal' |
| 130 | foreach func: check_freetype_funcs |
| 131 | name = func[0] |
| 132 | conf.set('HAVE_@0@'.format(name.to_upper()), 1) |
| 133 | endforeach |
| 134 | else |
| 135 | check_funcs += check_freetype_funcs |
| 136 | endif |
| 137 | endif |
| 138 | |
| 139 | if fontconfig_dep.found() |
| 140 | conf.set('HAVE_FONTCONFIG', 1) |
| 141 | deps += [fontconfig_dep] |
| 142 | endif |
| 143 | |
Tim-Philipp Müller | b7796a5 | 2018-11-12 16:56:56 +0000 | [diff] [blame] | 144 | # uniscribe (windows) - FIXME: untested |
| 145 | if host_machine.system() == 'windows' and not get_option('uniscribe').disabled() |
| 146 | # TODO: make nicer once we have https://github.com/mesonbuild/meson/issues/3940 |
| 147 | if cpp.has_header('usp10.h') and cpp.has_header('windows.h') |
| 148 | foreach usplib : ['usp10', 'gdi32', 'rpcrt4'] |
| 149 | deps += [cpp.find_library(usplib, required: true)] |
| 150 | endforeach |
| 151 | conf.set('HAVE_UNISCRIBE', 1) |
| 152 | elif get_option('uniscribe').enabled() |
| 153 | error('uniscribe was enabled explicitly, but some required headers are missing.') |
| 154 | endif |
| 155 | endif |
| 156 | |
Tim-Philipp Müller | 83ebbe4 | 2018-11-12 16:56:56 +0000 | [diff] [blame] | 157 | # DirectWrite (windows) - FIXME: untested |
| 158 | if host_machine.system() == 'windows' and not get_option('directwrite').disabled() |
| 159 | if cpp.has_header('dwrite.h') |
| 160 | deps += [cpp.find_library('dwrite', required: true)] |
| 161 | conf.set('HAVE_DIRECTWRITE', 1) |
| 162 | elif get_option('directwrite').enabled() |
| 163 | error('DirectWrite was enabled explicitly, but required header is missing.') |
| 164 | endif |
| 165 | endif |
| 166 | |
Tim-Philipp Müller | 4840c82 | 2018-11-12 16:56:56 +0000 | [diff] [blame] | 167 | # CoreText (macOS) - FIXME: untested |
| 168 | if host_machine.system() == 'darwin' and not get_option('coretext').disabled() |
| 169 | app_services_dep = dependency('appleframeworks', modules : ['ApplicationServices'], required: false) |
| 170 | if cpp.has_type('CTFontRef', prefix: '#include <ApplicationServices/ApplicationServices.h>', dependencies: app_services_dep) |
| 171 | deps += [app_services_dep] |
| 172 | conf.set('HAVE_CORETEXT', 1) |
| 173 | # On iOS CoreText and CoreGraphics are stand-alone frameworks |
| 174 | # Check for a different symbol to avoid getting cached result |
| 175 | else |
| 176 | coretext_dep = dependency('appleframeworks', modules : ['CoreText'], required: false) |
| 177 | coregraphics_dep = dependency('appleframeworks', modules : ['CoreGraphics'], required: false) |
| 178 | corefoundation_dep = dependency('appleframeworks', modules : ['CoreFoundation'], required: false) |
| 179 | if cpp.has_type('CTRunRef', prefix: '#include <CoreText/CoreText.h>', dependencies: [coretext_dep, coregraphics_dep, corefoundation_dep]) |
| 180 | deps += [coretext_dep, coregraphics_dep, corefoundation_dep] |
| 181 | conf.set('HAVE_CORETEXT', 1) |
| 182 | elif get_option('coretext').enabled() |
| 183 | error('CoreText was enabled explicitly, but required headers or frameworks are missing.') |
| 184 | endif |
| 185 | endif |
| 186 | endif |
| 187 | |
Tim-Philipp Müller | b7796a5 | 2018-11-12 16:56:56 +0000 | [diff] [blame] | 188 | # threads |
Mathieu Duponchelle | 920efc0 | 2018-05-17 01:28:53 +0200 | [diff] [blame] | 189 | if host_machine.system() != 'windows' |
| 190 | thread_dep = dependency('threads', required: false) |
| 191 | |
| 192 | if thread_dep.found() |
| 193 | conf.set('HAVE_PTHREAD', 1) |
| 194 | deps += [thread_dep] |
| 195 | else |
| 196 | check_headers += ['sched.h'] |
| 197 | check_funcs += ['sched_yield', {'link_with': 'rt'}] |
| 198 | endif |
| 199 | endif |
| 200 | |
Mathieu Duponchelle | 04bcdb9 | 2018-06-05 20:59:29 +0200 | [diff] [blame] | 201 | conf.set('HAVE_OT', 1) |
| 202 | conf.set('HAVE_FALLBACK', 1) |
Mathieu Duponchelle | 920efc0 | 2018-05-17 01:28:53 +0200 | [diff] [blame] | 203 | conf.set_quoted('PACKAGE_NAME', 'HarfBuzz') |
| 204 | conf.set_quoted('PACKAGE_VERSION', meson.project_version()) |
| 205 | |
| 206 | foreach check : check_headers |
| 207 | name = check[0] |
| 208 | |
| 209 | if cpp.has_header(name) |
| 210 | conf.set('HAVE_@0@'.format(name.to_upper().underscorify()), 1) |
| 211 | endif |
| 212 | endforeach |
| 213 | |
| 214 | foreach check : check_funcs |
| 215 | name = check[0] |
Mathieu Duponchelle | 04bcdb9 | 2018-06-05 20:59:29 +0200 | [diff] [blame] | 216 | opts = check.get(1, {}) |
Mathieu Duponchelle | 920efc0 | 2018-05-17 01:28:53 +0200 | [diff] [blame] | 217 | link_withs = opts.get('link_with', []) |
Mathieu Duponchelle | 04bcdb9 | 2018-06-05 20:59:29 +0200 | [diff] [blame] | 218 | check_deps = opts.get('deps', []) |
Mathieu Duponchelle | 920efc0 | 2018-05-17 01:28:53 +0200 | [diff] [blame] | 219 | extra_deps = [] |
| 220 | found = true |
| 221 | |
| 222 | # First try without linking |
| 223 | |
Mathieu Duponchelle | 04bcdb9 | 2018-06-05 20:59:29 +0200 | [diff] [blame] | 224 | found = cpp.has_function(name, dependencies: check_deps) |
Mathieu Duponchelle | 920efc0 | 2018-05-17 01:28:53 +0200 | [diff] [blame] | 225 | |
| 226 | if not found and link_withs.length() > 0 |
| 227 | found = true |
| 228 | |
| 229 | foreach link_with : link_withs |
| 230 | dep = cpp.find_library(link_with, required: false) |
| 231 | if dep.found() |
| 232 | extra_deps += dep |
| 233 | else |
| 234 | found = false |
| 235 | endif |
| 236 | endforeach |
| 237 | |
| 238 | if found |
Mathieu Duponchelle | 04bcdb9 | 2018-06-05 20:59:29 +0200 | [diff] [blame] | 239 | found = cpp.has_function(name, dependencies: check_deps + extra_deps) |
Mathieu Duponchelle | 920efc0 | 2018-05-17 01:28:53 +0200 | [diff] [blame] | 240 | endif |
| 241 | endif |
| 242 | |
| 243 | if found |
| 244 | deps += extra_deps |
| 245 | conf.set('HAVE_@0@'.format(name.to_upper()), 1) |
| 246 | endif |
| 247 | endforeach |
| 248 | |
Mathieu Duponchelle | 920efc0 | 2018-05-17 01:28:53 +0200 | [diff] [blame] | 249 | if cpp.links(files('meson-cc-tests/intel-atomic-primitives-test.c'), name: 'Intel atomics') |
| 250 | conf.set('HAVE_INTEL_ATOMIC_PRIMITIVES', 1) |
| 251 | endif |
| 252 | |
| 253 | if cpp.links(files('meson-cc-tests/solaris-atomic-operations.c'), name: 'Solaris atomic ops') |
| 254 | conf.set('HAVE_SOLARIS_ATOMIC_OPS', 1) |
| 255 | endif |
| 256 | |
| 257 | subdir('src') |
| 258 | subdir('util') |
Tim-Philipp Müller | 6147df3 | 2018-11-14 10:12:40 +0000 | [diff] [blame] | 259 | |
| 260 | if not get_option('tests').disabled() |
| 261 | subdir('test') |
| 262 | endif |
Mathieu Duponchelle | 920efc0 | 2018-05-17 01:28:53 +0200 | [diff] [blame] | 263 | |
| 264 | configure_file(output: 'config.h', configuration: conf) |