-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathmeson.build
More file actions
158 lines (140 loc) · 4.72 KB
/
meson.build
File metadata and controls
158 lines (140 loc) · 4.72 KB
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
project('json-glib', 'c', version: '1.3.1',
license: 'LGPLv2.1+',
default_options: [
'warning_level=1',
'buildtype=debugoptimized',
],
meson_version: '>= 0.37.1')
# Versionning
json_version = meson.project_version()
version_arr = json_version.split('.')
json_version_major = version_arr[0].to_int()
json_version_minor = version_arr[1].to_int()
json_version_micro = version_arr[2].to_int()
apiversion = '1.0'
soversion = 0
if json_version_minor.is_odd()
json_interface_age = 0
else
json_interface_age = json_version_micro
endif
# maintaining compatibility with the previous libtool versioning
# current = minor * 100 + micro - interface
# revision = interface
soversion = 0
current = json_version_minor * 100 + json_version_micro - json_interface_age
revision = json_interface_age
libversion = '@0@.@1@.@2@'.format(soversion, current, revision)
# Paths
json_includedir = join_paths(get_option('prefix'), get_option('includedir'))
json_datadir = join_paths(get_option('prefix'), get_option('datadir'))
json_mandir = join_paths(get_option('prefix'), get_option('mandir'))
json_localedir = join_paths(get_option('prefix'), get_option('localedir'))
json_libexecdir = join_paths(get_option('prefix'), get_option('libexecdir'))
# Dependencies
glib_req_version = '>= 2.44.0'
gobject_dep = dependency('gobject-2.0', version: glib_req_version)
gio_dep = dependency('gio-2.0', version: glib_req_version)
# Configurations
cc = meson.get_compiler('c')
host_system = host_machine.system()
extra_args = []
cdata = configuration_data()
check_headers = [
['unistd.h', 'HAVE_UNISTD_H'],
]
foreach h: check_headers
if cc.has_header(h.get(0))
cdata.set(h.get(1), 1)
endif
endforeach
cdata.set_quoted('GETTEXT_PACKAGE', 'json-glib-1.0')
if cc.get_id() == 'msvc'
# Compiler options taken from msvc_recommended_pragmas.h
# in GLib, based on _Win32_Programming_ by Rector and Newcomer
test_cflags = [
'-we4002', # too many actual parameters for macro
'-we4003', # not enough actual parameters for macro
'-w14010', # single-line comment contains line-continuation character
'-we4013', # 'function' undefined; assuming extern returning int
'-w14016', # no function return type; using int as default
'-we4020', # too many actual parameters
'-we4021', # too few actual parameters
'-we4027', # function declared without formal parameter list
'-we4029', # declared formal parameter list different from definition
'-we4033', # 'function' must return a value
'-we4035', # 'function' : no return value
'-we4045', # array bounds overflow
'-we4047', # different levels of indirection
'-we4049', # terminating line number emission
'-we4053', # an expression of type void was used as an operand
'-we4071', # no function prototype given
'-we4819', # the file contains a character that cannot be represented in the current code page
]
elif cc.get_id() == 'gcc' or cc.get_id() == 'clang'
test_cflags = [
'-Wpointer-arith',
'-Wmissing-declarations',
'-Wformat=2',
'-Wstrict-prototypes',
'-Wmissing-prototypes',
'-Wnested-externs',
'-Wold-style-definition',
'-Wdeclaration-after-statement',
'-Wunused',
'-Wno-uninitialized',
'-Wshadow',
'-Wcast-align',
'-Wmissing-noreturn',
'-Wmissing-format-attribute',
'-Wlogical-op',
'-Wno-discarded-qualifiers',
'-Werror=implicit',
'-Werror=nonnull',
'-Werror=init-self',
'-Werror=main',
'-Werror=missing-braces',
'-Werror=sequence-point',
'-Werror=return-type',
'-Werror=trigraphs',
'-Werror=array-bounds',
'-Werror=write-strings',
'-Werror=address',
'-Werror=int-to-pointer-cast',
'-Werror=pointer-to-int-cast',
'-Werror=empty-body',
'-fno-strict-aliasing',
'-Wno-int-conversion',
]
else
test_cflags = []
endif
common_cflags = []
foreach cflag: test_cflags
if cc.has_argument(cflag)
common_cflags += [ cflag ]
endif
endforeach
if get_option('default_library') != 'static'
if host_system == 'windows'
cdata.set('DLL_EXPORT', true)
if cc.get_id() == 'msvc'
cdata.set('_JSON_EXTERN', '__declspec(dllexport) extern')
else
cdata.set('_JSON_EXTERN', '__attribute__((visibility("default"))) __declspec(dllexport) extern')
extra_args += ['-fvisibility=hidden']
endif
else
cdata.set('_JSON_EXTERN', '__attribute__((visibility("default"))) extern')
extra_args += ['-fvisibility=hidden']
endif
endif
root_dir = include_directories('.')
gnome = import('gnome')
gir = find_program('g-ir-scanner', required: false)
build_gir = gir.found() and not meson.is_cross_build() and not get_option('disable_introspection')
subdir('json-glib')
subdir('po')
if get_option('enable-gtk-doc')
subdir('doc')
endif