blob: 9122b8d8c1b0f925c63658c005eed6082e9b9fdd [file] [log] [blame]
Mathieu Duponchelle920efc02018-05-17 01:28:53 +02001project('harfbuzz', 'c', 'cpp',
Mathieu Duponchelle07cadc92018-06-18 17:18:05 +02002 meson_version: '>= 0.47.0',
Mathieu Duponchelle920efc02018-05-17 01:28:53 +02003 version: '1.7.6')
4
Mathieu Duponchelle484313f2018-06-05 02:15:43 +02005pkgmod = import('pkgconfig')
Mathieu Duponchelle920efc02018-05-17 01:28:53 +02006cpp = meson.get_compiler('cpp')
7
8python3 = import('python').find_installation('python3')
9
10check_headers = [
11 ['unistd.h'],
12 ['sys/mman.h'],
13 ['xlocale.h'],
14 ['stdbool.h'],
15]
16
17check_funcs = [
18 ['atexit'],
19 ['mprotect'],
20 ['sysconf'],
21 ['getpagesize'],
22 ['mmap'],
23 ['isatty'],
24 ['newlocale'],
25 ['strtod_l'],
26 ['round'],
27]
28
Tim-Philipp Müller49ba2112018-11-12 15:36:27 +000029freetype_dep = dependency('freetype2', required: get_option('freetype'),
Nirbheek Chauhanf65def42018-10-12 19:41:49 +053030 fallback: ['freetype2', 'freetype_dep'])
Tim-Philipp Müller49ba2112018-11-12 15:36:27 +000031glib_dep = dependency('glib-2.0', required: get_option('glib'),
Nirbheek Chauhanf65def42018-10-12 19:41:49 +053032 fallback: ['glib', 'libglib_dep'])
Tim-Philipp Müller49ba2112018-11-12 15:36:27 +000033gobject_dep = dependency('gobject-2.0', required: get_option('gobject'),
Nirbheek Chauhanf65def42018-10-12 19:41:49 +053034 fallback: ['glib', 'libgobject_dep'])
Tim-Philipp Müller49ba2112018-11-12 15:36:27 +000035cairo_dep = dependency('cairo', required: get_option('cairo'),
Nirbheek Chauhanf65def42018-10-12 19:41:49 +053036 fallback: ['cairo', 'libcairo_dep'])
Tim-Philipp Müller49ba2112018-11-12 15:36:27 +000037fontconfig_dep = dependency('fontconfig', required: get_option('fontconfig'),
Nirbheek Chauhanf65def42018-10-12 19:41:49 +053038 fallback: ['fontconfig', 'fontconfig_dep'])
Tim-Philipp Müller49ba2112018-11-12 15:36:27 +000039graphite2_dep = dependency('graphite2', required: get_option('graphite'))
40icu_dep = dependency('icu-uc', required: get_option('icu'))
Mathieu Duponchellefce88f92018-05-17 16:20:10 +020041m_dep = cpp.find_library('m', required: false)
Mathieu Duponchelle920efc02018-05-17 01:28:53 +020042
Nirbheek Chauhanf65def42018-10-12 19:41:49 +053043# Ensure that cairo-ft is fetched from the same library as cairo itself
44if cairo_dep.found()
45 if cairo_dep.type_name() == 'pkgconfig'
Tim-Philipp Müller49ba2112018-11-12 15:36:27 +000046 cairo_ft_dep = dependency('cairo-ft', required: get_option('cairo'))
Nirbheek Chauhanf65def42018-10-12 19:41:49 +053047 else
48 cairo_ft_dep = cairo_dep
49 endif
50else
51 # Not-found dependency
52 cairo_ft_dep = dependency('', required: false)
53endif
54
Mathieu Duponchellefce88f92018-05-17 16:20:10 +020055deps = []
Mathieu Duponchelle920efc02018-05-17 01:28:53 +020056
57conf = configuration_data()
58incbase = include_directories('.')
59cpp_args = ['-DHAVE_CONFIG_H']
60
61warn_cflags = [
62 '-Wno-non-virtual-dtor',
63]
64
65cpp_args += cpp.get_supported_arguments(warn_cflags)
66
Mathieu Duponchellefce88f92018-05-17 16:20:10 +020067if m_dep.found()
68 deps += [m_dep]
69endif
70
Mathieu Duponchelle920efc02018-05-17 01:28:53 +020071if glib_dep.found()
72 conf.set('HAVE_GLIB', 1)
73 deps += [glib_dep]
74endif
75
76if gobject_dep.found()
77 conf.set('HAVE_GOBJECT', 1)
78 deps += [gobject_dep]
79endif
80
81if cairo_dep.found()
82 conf.set('HAVE_CAIRO', 1)
83 deps += [cairo_dep]
84endif
85
86if cairo_ft_dep.found()
87 conf.set('HAVE_CAIRO_FT', 1)
88 deps += [cairo_ft_dep]
89endif
90
91if graphite2_dep.found()
92 conf.set('HAVE_GRAPHITE2', 1)
93 deps += [graphite2_dep]
94endif
95
96if icu_dep.found()
97 conf.set('HAVE_ICU', 1)
98 conf.set('HAVE_ICU_BUILTIN', 1)
99 deps += [icu_dep]
100endif
101
102if freetype_dep.found()
103 conf.set('HAVE_FREETYPE', 1)
104 deps += [freetype_dep]
Mathieu Duponchelle04bcdb92018-06-05 20:59:29 +0200105 check_freetype_funcs = [
106 ['FT_Get_Var_Blend_Coordinates', {'deps': freetype_dep}],
107 ['FT_Set_Var_Blend_Coordinates', {'deps': freetype_dep}],
108 ['FT_Done_MM_Var', {'deps': freetype_dep}],
109 ]
Mathieu Duponchelle920efc02018-05-17 01:28:53 +0200110
111 if freetype_dep.type_name() == 'internal'
112 foreach func: check_freetype_funcs
113 name = func[0]
114 conf.set('HAVE_@0@'.format(name.to_upper()), 1)
115 endforeach
116 else
117 check_funcs += check_freetype_funcs
118 endif
119endif
120
121if fontconfig_dep.found()
122 conf.set('HAVE_FONTCONFIG', 1)
123 deps += [fontconfig_dep]
124endif
125
Tim-Philipp Müllerb7796a52018-11-12 16:56:56 +0000126# uniscribe (windows) - FIXME: untested
127if host_machine.system() == 'windows' and not get_option('uniscribe').disabled()
128 # TODO: make nicer once we have https://github.com/mesonbuild/meson/issues/3940
129 if cpp.has_header('usp10.h') and cpp.has_header('windows.h')
130 foreach usplib : ['usp10', 'gdi32', 'rpcrt4']
131 deps += [cpp.find_library(usplib, required: true)]
132 endforeach
133 conf.set('HAVE_UNISCRIBE', 1)
134 elif get_option('uniscribe').enabled()
135 error('uniscribe was enabled explicitly, but some required headers are missing.')
136 endif
137endif
138
139# threads
Mathieu Duponchelle920efc02018-05-17 01:28:53 +0200140if host_machine.system() != 'windows'
141 thread_dep = dependency('threads', required: false)
142
143 if thread_dep.found()
144 conf.set('HAVE_PTHREAD', 1)
145 deps += [thread_dep]
146 else
147 check_headers += ['sched.h']
148 check_funcs += ['sched_yield', {'link_with': 'rt'}]
149 endif
150endif
151
Mathieu Duponchelle04bcdb92018-06-05 20:59:29 +0200152conf.set('HAVE_OT', 1)
153conf.set('HAVE_FALLBACK', 1)
Mathieu Duponchelle920efc02018-05-17 01:28:53 +0200154conf.set_quoted('PACKAGE_NAME', 'HarfBuzz')
155conf.set_quoted('PACKAGE_VERSION', meson.project_version())
156
157foreach check : check_headers
158 name = check[0]
159
160 if cpp.has_header(name)
161 conf.set('HAVE_@0@'.format(name.to_upper().underscorify()), 1)
162 endif
163endforeach
164
165foreach check : check_funcs
166 name = check[0]
Mathieu Duponchelle04bcdb92018-06-05 20:59:29 +0200167 opts = check.get(1, {})
Mathieu Duponchelle920efc02018-05-17 01:28:53 +0200168 link_withs = opts.get('link_with', [])
Mathieu Duponchelle04bcdb92018-06-05 20:59:29 +0200169 check_deps = opts.get('deps', [])
Mathieu Duponchelle920efc02018-05-17 01:28:53 +0200170 extra_deps = []
171 found = true
172
173 # First try without linking
174
Mathieu Duponchelle04bcdb92018-06-05 20:59:29 +0200175 found = cpp.has_function(name, dependencies: check_deps)
Mathieu Duponchelle920efc02018-05-17 01:28:53 +0200176
177 if not found and link_withs.length() > 0
178 found = true
179
180 foreach link_with : link_withs
181 dep = cpp.find_library(link_with, required: false)
182 if dep.found()
183 extra_deps += dep
184 else
185 found = false
186 endif
187 endforeach
188
189 if found
Mathieu Duponchelle04bcdb92018-06-05 20:59:29 +0200190 found = cpp.has_function(name, dependencies: check_deps + extra_deps)
Mathieu Duponchelle920efc02018-05-17 01:28:53 +0200191 endif
192 endif
193
194 if found
195 deps += extra_deps
196 conf.set('HAVE_@0@'.format(name.to_upper()), 1)
197 endif
198endforeach
199
Mathieu Duponchelle920efc02018-05-17 01:28:53 +0200200if cpp.links(files('meson-cc-tests/intel-atomic-primitives-test.c'), name: 'Intel atomics')
201 conf.set('HAVE_INTEL_ATOMIC_PRIMITIVES', 1)
202endif
203
204if cpp.links(files('meson-cc-tests/solaris-atomic-operations.c'), name: 'Solaris atomic ops')
205 conf.set('HAVE_SOLARIS_ATOMIC_OPS', 1)
206endif
207
208subdir('src')
209subdir('util')
210subdir('test')
211
212configure_file(output: 'config.h', configuration: conf)