forked from fchapoton/cairo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
meson.build
993 lines (862 loc) · 29.4 KB
/
meson.build
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
project('cairo', 'c', 'cpp',
meson_version: '>= 0.56.0',
version: run_command(find_program('version.py'), check: true).stdout().strip(),
default_options: ['warning_level=2'],
)
# Keep in sync with configure.ac!
freetype_required_version = '>= 9.7.3'
fontconfig_required_version = '>= 2.2.95'
xrender_required_version = '>= 0.6'
xcb_required_version = '>= 1.6'
xcb_render_required_version = '>= 1.6'
libudev_required_version = '>= 136'
glib_required_version = '>= 2.14'
# library versioning
version_arr = meson.project_version().split('.')
cairo_version_major = version_arr[0].to_int()
cairo_version_minor = version_arr[1].to_int()
cairo_version_micro = version_arr[2].to_int()
# The libtool shared library version stuff.
# Try and maintain compatibility with the previous library versioning.
cairo_version_sonum = cairo_version_major + 1
cairo_version = cairo_version_major * 10000 + cairo_version_minor * 100 + cairo_version_micro
if cairo_version_minor % 2 == 1
# unstable release
cairo_libversion = '@0@.@[email protected]'.format(cairo_version_sonum, cairo_version)
else
# stable release
cairo_libversion = '@0@.@1@.@2@'.format(cairo_version_sonum, cairo_version, cairo_version_micro)
endif
conf = configuration_data()
cc = meson.get_compiler('c')
# Compiler flags
cflags = []
if cc.get_id() != 'msvc'
cflags += [
'-Wmissing-declarations',
'-Werror-implicit-function-declaration',
'-Wpointer-arith',
'-Wwrite-strings',
'-Wsign-compare',
'-Wpacked',
'-Wswitch-enum',
'-Wmissing-format-attribute',
'-Wvolatile-register-var',
'-Wstrict-aliasing=2',
'-Winit-self',
'-Wunsafe-loop-optimizations',
'-Wno-missing-field-initializers',
'-Wno-unused-parameter',
'-Wno-attributes',
'-Wno-long-long',
'-Winline'
]
cflags += ['-Wno-unused-but-set-variable',
'-Wno-enum-conversion'
]
cflags += [
'-fno-strict-aliasing',
'-fno-common'
]
if get_option('optimization') in ['1', '2', '3']
cflags += ['-Wp,-D_FORTIFY_SOURCE=2', '-Wl,-lssp']
endif
supported_cflags = cc.get_supported_arguments(cflags)
add_project_arguments(supported_cflags, language: 'c')
# We only wish to enable attribute(warn_unused_result) if we can prevent
# gcc from generating thousands of warnings about the misapplication of the
# attribute to void functions and variables.
warn_unused_result = ''
if supported_cflags.contains('-Wno-attributes')
if cc.compiles(files('meson-cc-tests/check-unused-result.c'), args : ['-Wno-attributes', '-Werror'])
warn_unused_result = '__attribute__((__warn_unused_result__))'
endif
endif
conf.set('WARN_UNUSED_RESULT', warn_unused_result)
endif
if cc.get_id() == 'msvc'
# Basic usage in the cairo type system that causes spammy and useless warnings
add_project_arguments('/wd4244', '/wd4146',
# Don't warn about double -> float truncation
'/wd4305',
language : 'c')
endif
add_project_arguments('-D_GNU_SOURCE', language: 'c')
# Autotools compatibility
add_project_arguments('-DHAVE_CONFIG_H', language: 'c')
# Make sure source directory hasn't been configured with autotools
fs = import('fs')
if fs.exists('config.h') or fs.exists('src/cairo-features.h') or fs.exists('src/cairo-supported-features.h')
error('''
The source directory '@0@' appears to contain
autotools configuration artifacts. This can cause difficult to
debug build problems. Please clean it up and then re-run meson.
'''.format(meson.source_root()))
endif
pkgmod = import('pkgconfig')
python3 = import('python').find_installation()
check_sizeofs = [
['void *', {'conf-name': 'SIZEOF_VOID_P'}],
['int'],
['long'],
['long long'],
['size_t'],
]
check_headers = [
['stdint.h'],
['inttypes.h'],
['sys/int_types.h'],
['fcntl.h'],
['unistd.h'],
['signal.h'],
['sys/stat.h'],
['sys/socket.h'],
['poll.h'],
['sys/poll.h'],
['sys/un.h'],
['sched.h', {'check-funcs': ['sched_getaffinity']}],
['sys/mman.h', {'check-funcs': ['mmap']}],
['time.h', {'check-funcs': ['clock_gettime']}],
['libgen.h'],
['byteswap.h'],
['signal.h'],
['setjmp.h'],
['fenv.h'],
['sys/wait.h'],
['sys/stat.h'],
['io.h'],
['fenv.h', {'check-funcs': ['feenableexcept', 'fedisableexcept', 'feclearexcept']}],
['xlocale.h'],
['sys/ioctl.h'],
['intsafe.h'],
]
check_types = [
['uint64_t', {'headers': ['stdint.h']}],
['uint128_t', {'headers': ['stdint.h']}],
['__uint128_t']
]
check_funcs = [
'alarm',
'ctime_r',
'localtime_r',
'gmtime_r',
'drand48',
'flockfile',
'funlockfile',
'getline',
'link',
'fork',
'waitpid',
'raise',
'newlocale',
'strtod_l',
]
check_thread_flags = [
[['-D_REENTRANT'], ['-lpthread']],
[['-pthread'], []],
[['-D_REENTRANT'], [], {'real': false}],
]
m_dep = cc.find_library('m', required: false)
# Used in util
gtk_dep = dependency('gtk+-2.0', required: get_option('gtk2-utils'))
deps = [m_dep]
test_deps = []
internal_deps = []
extra_link_args = []
if host_machine.endian() == 'big'
conf.set('WORDS_BIGENDIAN', 1)
endif
float_order = cc.get_define('__FLOAT_WORD_ORDER__')
if float_order != ''
if float_order == cc.get_define('__ORDER_BIG_ENDIAN__')
conf.set('FLOAT_WORDS_BIGENDIAN', 1)
endif
else
# Assume same as platform endian
if host_machine.endian() == 'big'
conf.set('FLOAT_WORDS_BIGENDIAN', 1)
endif
endif
lzo_dep = dependency('lzo2', required: false)
if lzo_dep.found()
conf.set('HAVE_LZO', 1)
endif
dl_dep = cc.find_library('dl', required: false)
if dl_dep.found() and cc.has_function('dlsym', dependencies: [dl_dep])
deps += [dl_dep]
conf.set('CAIRO_HAS_DLSYM', 1)
elif cc.has_function('dlsym')
conf.set('CAIRO_HAS_DLSYM', 1)
elif cc.has_function('dlsym', prefix: '#include <dlfcn.h>')
conf.set('CAIRO_HAS_DLSYM', 1)
endif
feature_conf = configuration_data()
# Array of dictionaries, used to generate per-feature pc files
# Mandatory keys: name, description
# Optional keys: requires, libs
built_features = []
zlib_dep = dependency('zlib',
required: get_option('zlib'),
fallback : ['zlib', 'zlib_dep'],
)
if zlib_dep.found()
if zlib_dep.type_name() == 'internal'
internal_deps += [zlib_dep]
else
deps += [zlib_dep]
endif
conf.set('HAVE_ZLIB', 1)
endif
png_dep = dependency('libpng',
required: get_option('png'),
fallback: ['libpng', 'libpng_dep']
)
if png_dep.found()
feature_conf.set('CAIRO_HAS_SVG_SURFACE', 1)
feature_conf.set('CAIRO_HAS_PNG_FUNCTIONS', 1)
built_features += [
{
'name': 'cairo-png',
'description': 'PNG functions',
'deps': [png_dep],
},
{
'name': 'cairo-svg',
'description': 'SVG surface backend',
'deps': [png_dep],
}
]
if png_dep.type_name() == 'internal'
internal_deps += [png_dep]
else
deps += [png_dep]
endif
endif
# Don't build fontconfig as a subproject on Windows unless
# explicitly requested
fontconfig_option = get_option('fontconfig')
if host_machine.system() == 'windows' and not fontconfig_option.enabled()
fontconfig_option = false
endif
fontconfig_dep = dependency('fontconfig',
required: fontconfig_option,
version: fontconfig_required_version,
fallback: ['fontconfig', 'fontconfig_dep'],
)
if fontconfig_dep.found()
fc_check_funcs = [
'FcInit',
'FcFini'
]
if fontconfig_dep.type_name() == 'internal'
foreach func : fc_check_funcs
conf.set('HAVE_@0@'.format(func.to_upper()), 1)
endforeach
internal_deps += [fontconfig_dep]
else
check_funcs += fc_check_funcs
deps += [fontconfig_dep]
endif
feature_conf.set('CAIRO_HAS_FC_FONT', 1)
built_features += [{
'name': 'cairo-fc',
'description': 'Fontconfig font backend',
'deps': [fontconfig_dep],
}]
endif
freetype_dep = dependency('freetype2',
required: get_option('freetype'),
version: freetype_required_version,
fallback: ['freetype2', 'freetype_dep'],
)
if freetype_dep.found()
feature_conf.set('CAIRO_HAS_FT_FONT', 1)
built_features += [{
'name': 'cairo-ft',
'description': 'Freetype font backend',
'deps': [freetype_dep],
# cairo-ft.h includes fontconfig.h so it needs its cflags
'compile-deps': [fontconfig_dep.partial_dependency(compile_args: true, includes: true)],
}]
ft_check_funcs = [
'FT_Get_X11_Font_Format',
'FT_GlyphSlot_Embolden',
'FT_GlyphSlot_Oblique',
'FT_Load_Sfnt_Table',
'FT_Library_SetLcdFilter',
'FT_Get_Var_Design_Coordinates',
'FT_Done_MM_Var',
'FT_Palette_Select',
]
if freetype_dep.type_name() == 'internal'
foreach func : ft_check_funcs
conf.set('HAVE_@0@'.format(func.to_upper()), 1)
endforeach
internal_deps += [freetype_dep]
else
if not cc.links(files('meson-cc-tests/ft_has_color.c'), dependencies: freetype_dep, name: 'FT has color')
conf.set('FT_HAS_COLOR', '(0)')
endif
check_funcs += ft_check_funcs
deps += [freetype_dep]
endif
endif
x11_dep = dependency('x11', required: get_option('xlib'))
xext_dep = dependency('xext', required: get_option('xlib'))
if x11_dep.found() and xext_dep.found()
feature_conf.set('CAIRO_HAS_XLIB_SURFACE', 1)
built_features += [{
'name': 'cairo-xlib',
'description': 'Xlib surface backend',
'deps': [x11_dep, xext_dep],
}]
extra_headers = ['X11/Xlibint.h', 'X11/Xproto.h']
check_headers += [
['X11/extensions/XShm.h', {'extra-headers': extra_headers}],
['X11/extensions/shmproto.h', {'extra-headers': extra_headers}],
['X11/extensions/shmstr.h', {'extra-headers': extra_headers}],
]
deps += [x11_dep, xext_dep]
# Can skip the run check by providing the result in a cross file or
# native file as bool property value.
prop = meson.get_external_property('ipc_rmid_deferred_release', 'auto')
# We don't know the type of prop (bool, string) but need to differentiate
# between a set value (bool) or the fallback value (string), so convert to
# a string and check the string value.
prop_str = '@0@'.format(prop)
if prop_str in ['true', 'false']
ipc_rmid_deferred_release = (prop_str == 'true')
message('IPC_RMID_DEFERRED_RELEASE:', ipc_rmid_deferred_release)
elif prop_str == 'auto'
res = cc.run(files('meson-cc-tests/ipc_rmid_deferred_release.c'),
dependencies: [x11_dep, xext_dep],
name: 'shmctl IPC_RMID allowes subsequent attaches')
ipc_rmid_deferred_release = (res.returncode() == 0)
else
error('Unexpected value for external property ipc_rmid_deferred_release: @0@'.format(prop_str))
endif
conf.set10('IPC_RMID_DEFERRED_RELEASE', ipc_rmid_deferred_release)
endif
if feature_conf.get('CAIRO_HAS_XLIB_SURFACE', 0) == 1
xrender_dep = dependency('xrender', required: get_option('xlib'),
version: xrender_required_version)
if xrender_dep.found()
check_funcs += [
'XRenderCreateSolidFill',
'XRenderCreateLinearGradient',
'XRenderCreateRadialGradient',
'XRenderCreateConicalGradient',
]
deps += [xrender_dep]
built_features += [{
'name': 'cairo-xlib-xrender',
'description': 'Xlib Xrender surface backend',
'deps': [xrender_dep],
}]
feature_conf.set('CAIRO_HAS_XLIB_XRENDER_SURFACE', 1)
endif
endif
xcb_dep = dependency('xcb', required: get_option('xcb'),
version: xcb_required_version)
xcb_render_dep = dependency('xcb-render', required: get_option('xcb'),
version: xcb_render_required_version)
if xcb_dep.found() and xcb_render_dep.found()
feature_conf.set('CAIRO_HAS_XCB_SURFACE', 1)
built_features += [{
'name': 'cairo-xcb',
'description': 'XCB surface backend',
'deps': [xcb_dep, xcb_render_dep],
}]
deps += [xcb_dep, xcb_render_dep]
endif
if feature_conf.get('CAIRO_HAS_XCB_SURFACE', 0) == 1 and feature_conf.get('CAIRO_HAS_XLIB_SURFACE', 0) == 1
x11xcb_dep = dependency('x11-xcb', required: get_option('xlib-xcb'))
if x11xcb_dep.found()
deps += [x11xcb_dep]
feature_conf.set('CAIRO_HAS_XLIB_XCB_FUNCTIONS', 1)
built_features += [{
'name': 'cairo-xlib-xcb',
'description': 'Xlib/XCB functions',
'deps': [x11xcb_dep],
}]
endif
endif
if feature_conf.get('CAIRO_HAS_XCB_SURFACE', 0) == 1
xcbshm_dep = dependency('xcb-shm', required: get_option('xcb'))
if xcbshm_dep.found()
feature_conf.set('CAIRO_HAS_XCB_SHM_FUNCTIONS', 1)
deps += [xcbshm_dep]
built_features += [{
'name': 'cairo-xcb-shm',
'description': 'XCB/SHM functions',
'deps': [xcbshm_dep],
}]
endif
endif
if host_machine.system() == 'darwin' and not get_option('quartz').disabled()
quartz_deps = dependency('appleframeworks', modules : ['CoreFoundation', 'ApplicationServices'], required: get_option('quartz'))
if quartz_deps.found()
deps += [quartz_deps]
feature_conf.set('CAIRO_HAS_QUARTZ_SURFACE', 1)
feature_conf.set('CAIRO_HAS_QUARTZ_IMAGE_SURFACE', 1)
built_features += [
{
'name': 'cairo-quartz',
'description': 'Quartz surface backend',
'deps': quartz_deps,
},
{
'name': 'cairo-quartz-image',
'description': 'Quartz Image surface backend',
'deps': quartz_deps,
}]
compiler = meson.get_compiler('c')
if compiler.has_function('CTFontDrawGlyphs', prefix: '#include <ApplicationServices/ApplicationServices.h>',
dependencies: quartz_deps)
built_features += [
{
'name': 'cairo-quartz-font',
'description': 'Quartz font backend',
'deps': quartz_deps,
}]
feature_conf.set('CAIRO_HAS_QUARTZ_FONT', 1)
endif
endif
endif
if host_machine.system() == 'windows'
win32_extra_deps = [
cc.find_library('gdi32'),
cc.find_library('msimg32'),
]
deps += win32_extra_deps
feature_conf.set('CAIRO_HAS_WIN32_SURFACE', 1)
feature_conf.set('CAIRO_HAS_WIN32_FONT', 1)
built_features += [
{
'name': 'cairo-win32',
'description': 'Microsoft Windows surface backend',
'deps': win32_extra_deps,
},
{
'name': 'cairo-win32-font',
'description': 'Microsoft Windows font backend',
'deps': win32_extra_deps,
}
]
cpp_compiler = meson.get_compiler('cpp')
d2d_dep = cpp_compiler.find_library('d2d1', required: false)
dwrite_dep = cpp_compiler.find_library('dwrite', required: false)
d2d_header = cpp_compiler.has_header('d2d1.h')
d2d_3_header = cpp_compiler.has_header('d2d1_3.h')
dwrite_header = cpp_compiler.has_header('dwrite.h')
dwrite_3_header = cpp_compiler.has_header('dwrite_3.h')
wincodec_dep = cpp_compiler.find_library('windowscodecs', required: false)
wincodec_header = cpp_compiler.has_header('wincodec.h')
if d2d_dep.found() and dwrite_dep.found() and d2d_header and dwrite_header and wincodec_dep.found() and wincodec_header
feature_conf.set('CAIRO_HAS_DWRITE_FONT', 1)
built_features += [{
'name': 'cairo-win32-dwrite-font',
'description': 'Microsoft Windows DWrite font backend',
'deps': [dwrite_dep, d2d_dep, wincodec_dep],
}]
deps += [dwrite_dep, d2d_dep, wincodec_dep]
if cpp_compiler.has_header('d2d1_3.h')
conf.set('HAVE_D2D1_3_H', 1)
endif
# Exclude MinGW dwrite_3.h because it has a broken definition of DWRITE_COLOR_GLYPH_RUN1.
if cpp_compiler.has_header('dwrite_3.h') and cpp_compiler.get_define('__MINGW32__') == ''
conf.set('HAVE_DWRITE_3_H', 1)
endif
endif
endif
# GL / GLESV2 / GLESV3 are mutually exclusive
gl_backend = get_option('gl-backend')
need_egl_functions = false
need_wgl_functions = false
need_glx_functions = false
if gl_backend in ['auto', 'gl']
gl_dep = dependency('gl', required: false)
if not gl_dep.found()
gl_dep = cc.find_library('GL', required: gl_backend == 'gl')
endif
if gl_dep.found() and \
cc.has_header('GL/gl.h', required: gl_backend == 'gl', dependencies: gl_dep) and \
cc.has_header('GL/glext.h', required: gl_backend == 'gl', dependencies: gl_dep)
deps += [gl_dep]
need_egl_functions = true
need_wgl_functions = true
need_glx_functions = true
feature_conf.set('CAIRO_HAS_GL_SURFACE', 1)
built_features += [{
'name': 'cairo-gl',
'description': 'OpenGL surface backend',
'deps': [gl_dep],
}]
endif
endif
if feature_conf.get('CAIRO_HAS_GL_SURFACE', 0) == 0 and ['auto', 'glesv2'].contains(gl_backend)
glesv2_dep = dependency('glesv2', required: false)
if not glesv2_dep.found()
glesv2_dep = cc.find_library('GLESv2', required: gl_backend == 'glesv2')
endif
if glesv2_dep.found() and \
cc.has_header('GLES2/gl2.h', required: gl_backend == 'glesv2', dependencies: glesv2_dep) and \
cc.has_header('GLES2/gl2ext.h', required: gl_backend == 'glesv2', dependencies: glesv2_dep)
deps += [glesv2_dep]
need_egl_functions = true
feature_conf.set('CAIRO_HAS_GLESV2_SURFACE', 1)
built_features += [{
'name': 'cairo-glesv2',
'source-key': 'cairo-gl',
'description': 'OpenGLESv2 surface backend',
'deps': [glesv2_dep],
}]
endif
endif
if feature_conf.get('CAIRO_HAS_GL_SURFACE', 0) == 0 and feature_conf.get('CAIRO_HAS_GLESV2_SURFACE', 0) == 0 and ['auto', 'glesv3'].contains(gl_backend)
# glesv3 is provided via libGLESv2.so (there is no libGLESv3, nor glesv3.pc)
glesv3_dep = dependency('glesv2', required: false)
if not glesv3_dep.found()
glesv3_dep = cc.find_library('GLESv2', required: gl_backend == 'glesv3')
endif
if glesv3_dep.found() and \
cc.has_header('GLES3/gl3.h', required: gl_backend == 'glesv3', dependencies: glesv3_dep) and \
cc.has_header('GLES3/gl3ext.h', required: gl_backend == 'glesv3', dependencies: glesv3_dep)
deps += [glesv3_dep]
need_egl_functions = true
feature_conf.set('CAIRO_HAS_GLESV3_SURFACE', 1)
built_features += [{
'name': 'cairo-glesv3',
'source-key': 'cairo-gl',
'description': 'OpenGLESv3 surface backend',
'deps': [glesv3_dep],
}]
endif
endif
if need_egl_functions
# FIXME: automagic
egl_extra_deps = []
egl_dep = dependency('egl', required: false)
if not egl_dep.found()
if cc.has_header('EGL/egl.h')
csi_dep = cc.find_library('csi', required: false)
if csi_dep.found() and cc.has_function('csi_stream_attachresource', dependencies: [csi_dep])
egl_extra_deps += csi_dep
endif
foreach libname : ['EGL', 'egl13', 'egl12', 'egl11']
dep = cc.find_library(libname, required: false)
if dep.found() and cc.has_function('eglGetError', dependencies: [dep])
egl_dep = dep
break
endif
endforeach
endif
endif
if egl_dep.found()
deps += egl_dep
feature_conf.set('CAIRO_HAS_EGL_FUNCTIONS', 1)
built_features += [{
'name': 'cairo-egl',
'description': 'EGL functions',
'deps': [egl_dep] + egl_extra_deps,
}]
endif
endif
if need_glx_functions
# FIXME: automagic
if cc.has_header('GL/glx.h')
feature_conf.set('CAIRO_HAS_GLX_FUNCTIONS', 1)
built_features += [{
'name': 'cairo-glx',
'description': 'GLX functions',
'deps': [cc.find_library('GL')],
}]
endif
endif
# Untested
if need_wgl_functions
# FIXME: automagic
if cc.has_header('windows.h')
feature_conf.set('CAIRO_HAS_WGL_FUNCTIONS', 1)
built_features += [{
'name': 'cairo-wgl',
'description': 'WGL functions',
}]
endif
endif
gobject_dep = dependency('gobject-2.0',
required: get_option('glib'),
fallback: ['glib', 'libgobject_dep']
)
glib_dep = dependency('glib-2.0',
required: get_option('glib'),
version: glib_required_version,
fallback: ['glib', 'libglib_dep'],
)
if gobject_dep.found() and glib_dep.found()
feature_conf.set('CAIRO_HAS_GOBJECT_FUNCTIONS', 1)
endif
if zlib_dep.found()
feature_conf.set('CAIRO_HAS_SCRIPT_SURFACE', 1)
built_features += [{
'name': 'cairo-script',
'description': 'script surface backend',
'deps': [zlib_dep],
}]
endif
if zlib_dep.found()
feature_conf.set('CAIRO_HAS_PS_SURFACE', 1)
built_features += [{
'name': 'cairo-ps',
'description': 'PostScript surface backend',
'deps': [zlib_dep],
}]
endif
if zlib_dep.found()
feature_conf.set('CAIRO_HAS_PDF_SURFACE', 1)
built_features += [{
'name': 'cairo-pdf',
'description': 'PDF surface backend',
'deps': [zlib_dep],
}]
endif
if zlib_dep.found()
conf.set('CAIRO_HAS_INTERPRETER', 1)
endif
if zlib_dep.found() and png_dep.found() and get_option('xml').enabled()
feature_conf.set('CAIRO_HAS_XML_SURFACE', 1)
built_features += [{
'name': 'cairo-xml',
'description': 'XML surface backend',
'deps': [zlib_dep],
}]
endif
bfd_dep = cc.find_library('bfd', has_headers: ['bfd.h'], required: get_option('symbol-lookup'))
if bfd_dep.found() and \
cc.has_function('bfd_openr', dependencies: [bfd_dep]) and \
cc.links(files('meson-cc-tests/bfd-section-flags.c'), name: 'bfd_section_flags', dependencies: bfd_dep)
conf.set('HAVE_BFD', 1)
deps += [bfd_dep]
elif get_option('symbol-lookup').enabled()
error('symbol lookup via bfd was enabled via options but is not available (bfd might be too old)')
endif
if conf.get('HAVE_BFD', 0) == 1
conf.set('CAIRO_HAS_SYMBOL_LOOKUP', 1)
endif
if feature_conf.get('CAIRO_HAS_PS_SURFACE', 0) == 1
gs = find_program('gs', required: get_option('tests'))
libspectre_dep = dependency('libspectre', version: '>= 0.2.0',
required: get_option('spectre'))
if gs.found() and libspectre_dep.found()
conf.set('CAIRO_CAN_TEST_PS_SURFACE', 1)
endif
if libspectre_dep.found()
conf.set('CAIRO_HAS_SPECTRE', 1)
test_deps += [libspectre_dep]
endif
endif
if feature_conf.get('CAIRO_HAS_PDF_SURFACE', 0) == 1
poppler_dep = dependency('poppler-glib', version: '>= 0.17.4',
required: get_option('tests'))
if poppler_dep.found() and cc.has_function('poppler_page_render', dependencies: [poppler_dep])
conf.set('CAIRO_CAN_TEST_PDF_SURFACE', 1)
test_deps += [poppler_dep]
endif
endif
if feature_conf.get('CAIRO_HAS_SVG_SURFACE', 0) == 1
librsvg_dep = dependency('librsvg-2.0', version: '>= 2.35.0',
required: get_option('tests'))
if librsvg_dep.found()
conf.set('CAIRO_CAN_TEST_SVG_SURFACE', 1)
test_deps += [librsvg_dep]
endif
endif
pixman_dep = dependency('pixman-1',
version: '>= 0.36.0',
fallback: ['pixman', 'idep_pixman'],
)
if pixman_dep.found()
feature_conf.set('CAIRO_HAS_IMAGE_SURFACE', 1)
conf.set('HAS_PIXMAN_GLYPHS', 1)
if pixman_dep.type_name() == 'internal'
internal_deps += [pixman_dep]
else
deps += [pixman_dep]
endif
endif
feature_conf.set('CAIRO_FEATURES_H', true)
feature_conf.set('CAIRO_HAS_USER_FONT', 1)
feature_conf.set('CAIRO_HAS_MIME_SURFACE', 1)
feature_conf.set('CAIRO_HAS_RECORDING_SURFACE', 1)
feature_conf.set('CAIRO_HAS_OBSERVER_SURFACE', 1)
if not get_option('tee').disabled()
feature_conf.set('CAIRO_HAS_TEE_SURFACE', 1)
built_features += [{
'name': 'cairo-tee',
'description': 'Tee surface backend',
}]
endif
incbase = include_directories('.')
foreach check : check_sizeofs
type = check[0]
opts = check.length() > 1 ? check[1] : {}
conf_name = opts.get('conf-name', 'SIZEOF_@0@'.format(type.underscorify().to_upper()))
conf.set(conf_name, cc.sizeof(type))
endforeach
foreach check : check_headers
name = check[0]
opts = check.length() > 1 ? check[1] : {}
prefix = ''
foreach header : opts.get('extra-headers', [])
prefix += '#include <@0@>\n'.format(header)
endforeach
if cc.has_header(name, prefix: prefix)
conf.set('HAVE_@0@'.format(name.to_upper().underscorify()), 1)
check_funcs += check.length() > 1 ? check[1].get('check-funcs', []) : []
endif
endforeach
foreach check : check_types
name = check[0]
opts = check.length() > 1 ? check[1] : {}
prefix = ''
foreach header : opts.get('headers', [])
prefix += '#include <@0@>\n'.format(header)
endforeach
if cc.has_type(name, prefix: prefix)
conf.set('HAVE_@0@'.format(name.to_upper()), 1)
endif
endforeach
foreach name : check_funcs
if cc.has_function(name, dependencies: deps)
conf.set('HAVE_@0@'.format(name.to_upper()), 1)
endif
endforeach
conf.set('HAVE_STRNDUP', cc.has_function('strndup', prefix : '#include <string.h>'))
pthread_c_args = []
pthread_link_args = []
foreach thread_flags : check_thread_flags
if not conf.has('CAIRO_HAS_PTHREAD')
cflags = thread_flags[0]
lflags = thread_flags[1]
real_pthread = thread_flags.length() > 2 ? thread_flags[2].get('real', true) : true
if cc.links(files('meson-cc-tests/pthread.c'), args: cflags + lflags, name: 'pthreads')
conf.set('CAIRO_HAS_PTHREAD', 1)
if real_pthread
conf.set('CAIRO_HAS_REAL_PTHREAD', 1)
endif
pthread_c_args = cflags
pthread_link_args = lflags
endif
endif
endforeach
extra_link_args += pthread_link_args
if cc.links(files('meson-cc-tests/atomic-ops-cxx11.c'), name: 'Atomic ops: cxx11')
conf.set('HAVE_CXX11_ATOMIC_PRIMITIVES', 1)
elif cc.links(files('meson-cc-tests/atomic-ops-gcc-legacy.c'), name: 'Atomic ops: gcc legacy')
conf.set('HAVE_GCC_LEGACY_ATOMICS', 1)
elif cc.has_header('atomic_ops.h')
conf.set('HAVE_LIB_ATOMIC_OPS', 1)
elif cc.has_header('libkern/OSAtomic.h')
conf.set('HAVE_OS_ATOMIC_OPS', 1)
endif
test_mkdir_c_args = []
if conf.get('HAVE_SYS_STAT_H', 0) == 1
test_mkdir_c_args += ['-DHAVE_SYS_STAT_H']
endif
if conf.get('HAVE_IO_H', 0) == 1
test_mkdir_c_args += ['-DHAVE_IO_H']
endif
if cc.links(files('meson-cc-tests/mkdir-variant-1.c'), args: test_mkdir_c_args)
conf.set('HAVE_MKDIR', 1)
elif cc.links(files('meson-cc-tests/mkdir-variant-2.c'), args: test_mkdir_c_args)
conf.set('HAVE_MKDIR', 2)
else
conf.set('HAVE_MKDIR', 0)
endif
if not ['x86', 'x86_64'].contains(host_machine.cpu_family())
conf.set('ATOMIC_OP_NEEDS_MEMORY_BARRIER', 1)
endif
have_ld_preload = ['linux', 'freebsd', 'darwin', 'dragonfly'].contains(host_machine.system())
if have_ld_preload and zlib_dep.found() and conf.get('CAIRO_HAS_REAL_PTHREAD', 0) == 1 and conf.get('CAIRO_HAS_DLSYM', 0) == 1
conf.set('CAIRO_HAS_TRACE', 1)
endif
rt_dep = cc.find_library('rt', required: false)
have_shm = false
if rt_dep.found() and cc.has_function('shm_open', dependencies: [rt_dep])
have_shm = true
endif
# This to make sure we don't run checks against internal deps
deps += internal_deps
subdir('src')
if feature_conf.get('CAIRO_HAS_PNG_FUNCTIONS', 0) == 1
subdir('boilerplate')
else
cairoboilerplate_dep = dependency('', required: false)
endif
subdir('util')
if not get_option('tests').disabled() and feature_conf.get('CAIRO_HAS_PNG_FUNCTIONS', 0) == 1
subdir('test')
subdir('perf')
endif
if get_option('gtk_doc')
doc_srcdir = include_directories('src')
subdir('doc/public')
endif
configure_file(output: 'config.h', configuration: conf)
foreach feature: built_features
feature_deps = feature.get('deps', [])
feature_libs = feature.get('libs', [])
feature_compile_deps = feature.get('compile-deps', [])
pkgmod.generate(libraries: [libcairo, feature_deps, feature_libs],
name: feature['name'],
description: feature['description'] + ' for cairo graphics library',
)
meson.override_dependency(feature['name'],
declare_dependency(dependencies: [libcairo_dep, feature_deps, feature_compile_deps],
link_args: feature_libs,
)
)
endforeach
# summary
summary({
'Image': true,
'Recording': true,
'Observer': true,
'Mime': true,
'Tee': feature_conf.get('CAIRO_HAS_TEE_SURFACE', 0) == 1,
'XML': feature_conf.get('CAIRO_HAS_XML_SURFACE', 0) == 1,
'Xlib': feature_conf.get('CAIRO_HAS_XLIB_SURFACE', 0) == 1,
'Xlib Xrender': feature_conf.get('CAIRO_HAS_XLIB_XRENDER_SURFACE', 0) == 1,
'Quartz': feature_conf.get('CAIRO_HAS_QUARTZ_SURFACE', 0) == 1,
'Quartz-image': feature_conf.get('CAIRO_HAS_QUARTZ_IMAGE_SURFACE', 0) == 1,
'XCB': feature_conf.get('CAIRO_HAS_XCB_SURFACE', 0) == 1,
'Win32': feature_conf.get('CAIRO_HAS_WIN32_SURFACE', 0) == 1,
'CairoScript': feature_conf.get('CAIRO_HAS_SCRIPT_SURFACE', 0) == 1,
'PostScript': feature_conf.get('CAIRO_HAS_PS_SURFACE', 0) == 1,
'PDF': feature_conf.get('CAIRO_HAS_PDF_SURFACE', 0) == 1,
'SVG': feature_conf.get('CAIRO_HAS_SVG_SURFACE', 0) == 1,
'OpenGL': feature_conf.get('CAIRO_HAS_GL_SURFACE', 0) == 1,
'OpenGL ES 2.0': feature_conf.get('CAIRO_HAS_GLESV2_SURFACE', 0) == 1,
'OpenGL ES 3.0': feature_conf.get('CAIRO_HAS_GLESV3_SURFACE', 0) == 1,
}, section: 'Surface Backends', bool_yn: true)
summary({
'User': true,
'FreeType': feature_conf.get('CAIRO_HAS_FT_FONT', 0) == 1,
'Fontconfig': feature_conf.get('CAIRO_HAS_FC_FONT', 0) == 1,
'Win32': feature_conf.get('CAIRO_HAS_WIN32_FONT', 0) == 1,
'Win32 DWrite': feature_conf.get('CAIRO_HAS_DWRITE_FONT', 0) == 1,
'Quartz': feature_conf.get('CAIRO_HAS_QUARTZ_FONT', 0) == 1,
}, section: 'Font Backends', bool_yn: true)
summary({
'PNG functions': feature_conf.get('CAIRO_HAS_PNG_FUNCTIONS', 0) == 1,
'GLX functions': feature_conf.get('CAIRO_HAS_GLX_FUNCTIONS', 0) == 1,
'WGL functions': feature_conf.get('CAIRO_HAS_WGL_FUNCTIONS', 0) == 1,
'EGL functions': feature_conf.get('CAIRO_HAS_EGL_FUNCTIONS', 0) == 1,
'X11-xcb': feature_conf.get('CAIRO_HAS_XLIB_XCB_FUNCTIONS', 0) == 1,
'XCB-shm': feature_conf.get('CAIRO_HAS_XCB_SHM_FUNCTIONS', 0) == 1,
}, section: 'Functions', bool_yn: true)
summary({
'cairo-trace:': conf.get('CAIRO_HAS_TRACE', 0) == 1,
'cairo-script-interpreter': conf.get('CAIRO_HAS_INTERPRETER', 0) == 1,
'API reference': get_option('gtk_doc'),
}, section: 'Features and Utilities', bool_yn: true)