-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmeson.build
291 lines (250 loc) · 7.17 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
#DNL -*- MODE: AUTOCONF; TAB-WIDTH: 4; INDENT-TABS-MODE: NIL; FILL-COLUMN: 102 -*-
# ==================
# Initialize Project
# ==================
project(
'libone',
['cpp'],
version : '0.0.90',
license : 'MPL 2.0+',
default_options : [
'cpp_std=c++11',
'debug=false',
'werror=true',
'warning_level=3',
],
)
project_description = 'A library to read and write MS-ONESTORE files'
project_basename = 'one'
# ====================
# Version informations
# ====================
libone_version = meson.project_version() # set in project() below
ver_arr = libone_version.split('.')
libone_major_version = ver_arr[0].to_int()
libone_minor_version = ver_arr[1].to_int()
libone_micro_version = ver_arr[2].to_int()
# ==========================
# platform specific compiler
# ==========================
cpp = meson.get_compiler('cpp')
# ===========
# Auto header
# ===========
cdata = configuration_data()
cdata.set10('HAVE_CONFIG_H', true)
cdata.set_quoted('PACKAGE', meson.project_name())
cdata.set_quoted('PACKAGE_NAME', meson.project_name())
cdata.set_quoted('PACKAGE_TARNAME', meson.project_name())
cdata.set_quoted('PACKAGE_STRING', meson.project_name() + ' ' + libone_version)
cdata.set_quoted('PACKAGE_VERSION', libone_version)
cdata.set_quoted('PACKAGE_URL', 'https://github.com/tshikaboom/libone/')
cdata.set_quoted('PACKAGE_BUGREPORT', '')
cdata.set_quoted('VERSION', libone_version)
doxygen = find_program('doxygen', required : true)
if doxygen.found()
cdata.set('HAVE_DOXYGEN', 1)
else
message('*** Could not find doxygen in your PATH.\n')
message('*** The documentation will not be built.\n')
endif
#
cdata.set10('DEBUG', get_option('debug'))
# Finalize and write config.h
configure_file(output : 'config.h',
configuration : cdata)
# ====================
# Find additional apps
# ====================
librevenge_dep = dependency('librevenge-0.0', required : true)
librevenge_generators_dep = dependency('librevenge-generators-0.0', required : true)
librevenge_stream_dep = dependency('librevenge-stream-0.0', required : true)
# =================================
# Libtool equivalent
# =================================
# TODO libary is currently without version spec in compiled file name
# libone_current_version= 100 * libone_major_version + libone_minor_version
# libone_age_version=0
#
# # soversion = current - age
# libone_soversion = '@0@'.format(libone_current_version - libone_age_version)
# ==============
# Platform check
# ==============
os_linux = false
os_win32 = false
os_cygwin = false
os_macos = false
host_system = host_machine.system()
if host_system == 'windows'
os_win32 = true
elif host_system == 'cygwin'
os_cygwin = true
elif host_system == 'linux'
os_linux = true
elif host_system == 'darwin'
os_macos = true
else
error('Unsopported OS.')
endif
# ==================
# Compiler arguments
# ==================
common_flags = ['-pedantic', '-Wshadow']
add_project_arguments(common_flags, language: 'cpp')
cpp_args = []
# Courtesy of Glib: Ensure MSVC-compatible struct packing convention
# is used when compiling for Win32 with gcc.
win32_cpp_args = []
win32_ldflags = []
if os_win32 and cc.get_id() != 'msvc'
# Ensure MSVC-compatible struct packing convention is used when
# compiling for Win32 with gcc. It is used for the whole project and exposed
win32_cpp_args += ['-mms-bitfields']
add_project_arguments(win32_cpp_args, language : 'cpp')
win32_ldflags = ['']
elif os_cygwin
win32_ldflags = ['']
else
message('produced libraries might be incompatible with MSVC-compiled code')
endif
if get_option('weffc')
cpp_args += ['-Weffc++']
endif
if get_option('wparanoic')
cpp_args += [
'-Wcast-align',
'-Wcast-qual',
'-Wchar-subscripts',
'-Wcomment',
'-Wconversion',
'-Wdisabled-optimization',
'-Wfloat-equal',
'-Wformat',
'-Wformat=2',
'-Wformat-nonliteral',
'-Wformat-security',
'-Wformat-y2k',
'-Wimport',
'-Winit-self',
'-Winvalid-pch',
'-Wmissing-braces',
'-Wmissing-field-initializers',
'-Wmissing-format-attribute',
'-Wmissing-include-dirs',
'-Wmissing-noreturn',
'-Wpacked',
'-Wparentheses',
'-Wpointer-arith',
'-Wredundant-decls',
'-Wreturn-type',
'-Wsequence-point',
'-Wsign-compare',
'-Wstrict-aliasing',
'-Wstrict-aliasing=2',
'-Wswitch',
'-Wswitch-default',
'-Wswitch-enum',
'-Wtrigraphs',
'-Wunknown-pragmas',
'-Wunused',
'-Wunused-function',
'-Wunused-label',
'-Wunused-parameter',
'-Wunused-value',
'-Wvariadic-macros',
'-Wvolatile-register-var',
'-Wwrite-strings',
]
endif
add_project_arguments(cpp_args, language: 'cpp')
# ============
# Debug switch
# ============
debug_cpp_args = []
if get_option('debug')
debug_cpp_args += ['-DDEBUG -g']
cpp_args += ['-O0']
else
debug_cpp_args += ['-DNDEBUG']
endif
add_project_arguments(debug_cpp_args, language: 'cpp')
# ==============
# Library Target
# ==============
libone_headers = [
'inc/libone/libone.h',
'inc/libone/ONEDocument.h'
]
libone_includes = include_directories('inc')
build_args = [
'-DPROJECT_NAME=' + meson.project_name(),
'-DPROJECT_VERSION=' + meson.project_version(),
]
# Only make public interfaces visible
if target_machine.system() == 'windows' or target_machine.system() == 'cygwin'
build_args += '-DLIBONE_PUBLIC="__declspec(dllexport)"'
else
build_args += '-DLIBONE_PUBLIC=__attribute__((visibility("default")))'
endif
subdir('src/lib')
# =========
# Packaging
# =========
# Make this library usable as a Meson subproject.
libone_dep = declare_dependency(
include_directories: [libone_includes],
link_with : libone_target
)
set_variable(meson.project_name() + '_dep', libone_dep)
# Make this library usable from the system's
# package manager.
install_headers(libone_headers,
subdir : meson.project_name() + '-' + libone_major_version.to_string() + '.' + libone_minor_version.to_string()
)
pkg_mod = import('pkgconfig')
pkg_mod.generate(
name : meson.project_name(),
filebase : meson.project_name(),
description : project_description,
subdirs : meson.project_name(),
libraries : libone_target,
)
# ==========
# Unit Tests
# ==========
if get_option('tests')
subdir('src/test')
endif
# ================
# Conversion tools
# ================
if get_option('tools')
subdir('src/conv')
endif
# =============
# Documentation
# =============
if get_option('docs')
if doxygen.found()
subdir('docs')
endif
endif
# ==============================================
# Display final informations about configuration
# ==============================================
summary({
'prefix': get_option('prefix'),
'libdir': get_option('libdir'),
'debug': get_option('debug'),
'docs': get_option('docs'),
'tests': get_option('tests'),
'tools': get_option('tools')},
section: 'Project options'
)
summary({
'werror': get_option('werror'),
'weffc': get_option('weffc'),
'wparanoic': get_option('wparanoic')},
section: 'Compiler options'
)