blob: aa7e36194291e31380bedee775c4fe6420802406 [file] [log] [blame]
Mathieu Duponchelle920efc02018-05-17 01:28:53 +02001project('harfbuzz', 'c', 'cpp',
2 version: '1.7.6')
3
4cpp = meson.get_compiler('cpp')
5
6python3 = import('python').find_installation('python3')
7
8check_headers = [
9 ['unistd.h'],
10 ['sys/mman.h'],
11 ['xlocale.h'],
12 ['stdbool.h'],
13]
14
15check_funcs = [
16 ['atexit'],
17 ['mprotect'],
18 ['sysconf'],
19 ['getpagesize'],
20 ['mmap'],
21 ['isatty'],
22 ['newlocale'],
23 ['strtod_l'],
24 ['round'],
25]
26
27check_freetype_funcs = [
28 ['FT_Get_Var_Blend_Coordinates'],
29 ['FT_Set_Var_Blend_Coordinates'],
30 ['FT_Done_MM_Var'],
31]
32
Mathieu Duponchellefce88f92018-05-17 16:20:10 +020033freetype_dep = dependency('freetype2', required: false, fallback: ['freetype2', 'freetype_dep'])
34glib_dep = dependency('glib-2.0', required: false, fallback: ['glib', 'libglib_dep'])
35gobject_dep = dependency('gobject-2.0', required: false, fallback: ['glib', 'libgobject_dep'])
Mathieu Duponchelle920efc02018-05-17 01:28:53 +020036cairo_dep = dependency('cairo', required: false)
37cairo_ft_dep = dependency('cairo-ft', required: false)
Mathieu Duponchellefce88f92018-05-17 16:20:10 +020038fontconfig_dep = dependency('fontconfig', required: false, fallback: ['fontconfig', 'fontconfig_dep'])
Mathieu Duponchelle920efc02018-05-17 01:28:53 +020039graphite2_dep = dependency('graphite2', required: false)
40icu_dep = dependency('icu-uc', required: false)
Mathieu Duponchellefce88f92018-05-17 16:20:10 +020041m_dep = cpp.find_library('m', required: false)
Mathieu Duponchelle920efc02018-05-17 01:28:53 +020042
Mathieu Duponchellefce88f92018-05-17 16:20:10 +020043deps = []
Mathieu Duponchelle920efc02018-05-17 01:28:53 +020044
45conf = configuration_data()
46incbase = include_directories('.')
47cpp_args = ['-DHAVE_CONFIG_H']
48
49warn_cflags = [
50 '-Wno-non-virtual-dtor',
51]
52
53cpp_args += cpp.get_supported_arguments(warn_cflags)
54
Mathieu Duponchellefce88f92018-05-17 16:20:10 +020055if m_dep.found()
56 deps += [m_dep]
57endif
58
Mathieu Duponchelle920efc02018-05-17 01:28:53 +020059if glib_dep.found()
60 conf.set('HAVE_GLIB', 1)
61 deps += [glib_dep]
62endif
63
64if gobject_dep.found()
65 conf.set('HAVE_GOBJECT', 1)
66 deps += [gobject_dep]
67endif
68
69if cairo_dep.found()
70 conf.set('HAVE_CAIRO', 1)
71 deps += [cairo_dep]
72endif
73
74if cairo_ft_dep.found()
75 conf.set('HAVE_CAIRO_FT', 1)
76 deps += [cairo_ft_dep]
77endif
78
79if graphite2_dep.found()
80 conf.set('HAVE_GRAPHITE2', 1)
81 deps += [graphite2_dep]
82endif
83
84if icu_dep.found()
85 conf.set('HAVE_ICU', 1)
86 conf.set('HAVE_ICU_BUILTIN', 1)
87 deps += [icu_dep]
88endif
89
90if freetype_dep.found()
91 conf.set('HAVE_FREETYPE', 1)
92 deps += [freetype_dep]
93
94 if freetype_dep.type_name() == 'internal'
95 foreach func: check_freetype_funcs
96 name = func[0]
97 conf.set('HAVE_@0@'.format(name.to_upper()), 1)
98 endforeach
99 else
100 check_funcs += check_freetype_funcs
101 endif
102endif
103
104if fontconfig_dep.found()
105 conf.set('HAVE_FONTCONFIG', 1)
106 deps += [fontconfig_dep]
107endif
108
109if host_machine.system() != 'windows'
110 thread_dep = dependency('threads', required: false)
111
112 if thread_dep.found()
113 conf.set('HAVE_PTHREAD', 1)
114 deps += [thread_dep]
115 else
116 check_headers += ['sched.h']
117 check_funcs += ['sched_yield', {'link_with': 'rt'}]
118 endif
119endif
120
121conf.set('HAVE_OT', true)
122conf.set('HAVE_FALLBACK', true)
123conf.set_quoted('PACKAGE_NAME', 'HarfBuzz')
124conf.set_quoted('PACKAGE_VERSION', meson.project_version())
125
126foreach check : check_headers
127 name = check[0]
128
129 if cpp.has_header(name)
130 conf.set('HAVE_@0@'.format(name.to_upper().underscorify()), 1)
131 endif
132endforeach
133
134foreach check : check_funcs
135 name = check[0]
136 opts = check.length() > 1 ? check[1] : {}
137 link_withs = opts.get('link_with', [])
138 extra_deps = []
139 found = true
140
141 # First try without linking
142
143 found = cpp.has_function(name)
144
145 if not found and link_withs.length() > 0
146 found = true
147
148 foreach link_with : link_withs
149 dep = cpp.find_library(link_with, required: false)
150 if dep.found()
151 extra_deps += dep
152 else
153 found = false
154 endif
155 endforeach
156
157 if found
158 found = cpp.has_function(name, dependencies: extra_deps)
159 endif
160 endif
161
162 if found
163 deps += extra_deps
164 conf.set('HAVE_@0@'.format(name.to_upper()), 1)
165 endif
166endforeach
167
Mathieu Duponchelle920efc02018-05-17 01:28:53 +0200168if cpp.links(files('meson-cc-tests/intel-atomic-primitives-test.c'), name: 'Intel atomics')
169 conf.set('HAVE_INTEL_ATOMIC_PRIMITIVES', 1)
170endif
171
172if cpp.links(files('meson-cc-tests/solaris-atomic-operations.c'), name: 'Solaris atomic ops')
173 conf.set('HAVE_SOLARIS_ATOMIC_OPS', 1)
174endif
175
176subdir('src')
177subdir('util')
178subdir('test')
179
180configure_file(output: 'config.h', configuration: conf)