forked from openMSX/openMSX
-
Notifications
You must be signed in to change notification settings - Fork 1
/
meson.build
193 lines (162 loc) · 5.26 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
project(
'openMSX', 'cpp',
license: 'GPL-2.0-only',
default_options: ['warning_level=3', 'cpp_std=c++20'],
meson_version: '>=0.50.0'
)
subdir('src')
# Compile Flags
# =============
compiler = meson.get_compiler('cpp')
if compiler.get_argument_syntax() == 'gcc'
# We support GCC and Clang.
# Additional warnings:
add_project_arguments('-Wundef', language: 'cpp')
add_project_arguments('-Wshadow', language: 'cpp')
add_project_arguments('-Wunused-macros', language: 'cpp')
add_project_arguments('-Wdouble-promotion', language: 'cpp')
add_project_arguments('-Wmissing-declarations', language: 'cpp')
add_project_arguments('-Wold-style-cast', language: 'cpp')
add_project_arguments('-Wzero-as-null-pointer-constant', language: 'cpp')
# Disable warnings that cause too many false positives:
add_project_arguments('-Wno-pedantic', language: 'cpp')
add_project_arguments('-Wno-invalid-offsetof', language: 'cpp')
# Hardware descriptions can contain constants that are not used in the code
# but still useful as documentation.
# The flag exists for both GCC and Clang, but GCC doesn't enable it via -Wall.
# We'll disable it for both, just in case GCC auto-enables it in the future.
add_project_arguments('-Wno-unused-const-variable', language: 'cpp')
endif
# Dependencies
# ============
dep_sdl2 = dependency('SDL2')
dep_sdl2_ttf = dependency('SDL2_ttf')
dep_png = dependency('libpng')
dep_tcl = dependency('tcl', version: '>=8.6.0')
dep_threads = dependency('threads')
dep_zlib = dependency('zlib')
dep_gl = dependency('GL', required: get_option('glrenderer'))
dep_glew = dependency('glew', required: get_option('glrenderer'))
dep_ogg = dependency('ogg', required: get_option('laserdisc'))
dep_theora = dependency('theoradec', required: get_option('laserdisc'))
dep_vorbis = dependency('vorbis', required: get_option('laserdisc'))
if host_machine.system() == 'linux'
dep_alsa = dependency('alsa', required: get_option('alsamidi'))
else
dep_alsa = dependency('', required: false)
endif
# Components
# ==========
components = {
'CORE':
true,
'GL':
not get_option('glrenderer').disabled()
and dep_gl.found() and dep_glew.found(),
'LASERDISC':
not get_option('laserdisc').disabled()
and dep_ogg.found() and dep_theora.found() and dep_vorbis.found(),
'ALSAMIDI':
not get_option('alsamidi').disabled()
and dep_alsa.found(),
}
# TODO: Subset the sources.
conf_components = configuration_data()
enabled_components = []
foreach name, enabled: components
conf_components.set10('COMPONENT_' + name, enabled)
if enabled
enabled_components += name
endif
endforeach
conf_components.set(
'BUILD_COMPONENTS', '"' + ' '.join(enabled_components) + '"'
)
hdr_components = configure_file(
output: 'components.hh',
configuration: conf_components
)
# System Functions
# ================
conf_systemfuncs = configuration_data()
conf_systemfuncs.set10(
'HAVE_FTRUNCATE',
compiler.has_function('ftruncate', prefix: '#include <unistd.h>')
)
if host_machine.system() in ['darwin', 'openbsd']
mmap_prefix = '\n'.join([
'#include <sys/types.h>',
'#include <sys/mman.h>'
])
else
mmap_prefix = '#include <sys/mman.h>'
endif
conf_systemfuncs.set10(
'HAVE_MMAP',
compiler.has_function('mmap', prefix: mmap_prefix)
)
conf_systemfuncs.set10(
'HAVE_NFTW',
compiler.has_function('nftw', prefix: '#include <ftw.h>')
)
conf_systemfuncs.set10(
'HAVE_POSIX_MEMALIGN',
compiler.has_function('posix_memalign', prefix: '#include <stdlib.h>')
)
hdr_systemfuncs = configure_file(
output: 'systemfuncs.hh',
configuration: conf_systemfuncs
)
# Other Generated Headers
# =======================
prog_python = import('python').find_installation('python3')
hdr_version = custom_target(
'version header',
output: 'Version.ii',
input: 'build/version2code.py',
command: [prog_python, '@INPUT@', '@OUTPUT@'],
build_always_stale: true,
)
abs_datadir = get_option('prefix') / get_option('datadir') / 'openmsx'
hdr_config = custom_target(
'build info header',
output: 'build-info.hh',
input: 'build/buildinfo2code.py',
command: [
prog_python, '@INPUT@', '@OUTPUT@',
host_machine.system(),
host_machine.cpu_family(), # TODO: is cpu() more suitable?
'devel', # OPENMSX_FLAVOUR
abs_datadir
],
)
# Targets
# =======
main_exec = executable(
'openmsx',
main_sources, sources,
hdr_version, hdr_config, hdr_components, hdr_systemfuncs,
install: true,
implicit_include_directories: false,
include_directories: [incdirs, '.'],
dependencies: [
dep_alsa, dep_gl, dep_glew, dep_ogg, dep_png, dep_sdl2, dep_sdl2_ttf,
dep_tcl, dep_theora, dep_threads, dep_vorbis, dep_zlib
],
)
objects = main_exec.extract_objects(sources)
test_exec = executable(
'unittest',
test_sources,
hdr_version, hdr_config, hdr_components, hdr_systemfuncs,
objects: objects,
build_by_default: false,
install: false,
implicit_include_directories: false,
include_directories: [incdirs, '.', 'Contrib/catch2'],
dependencies: [
dep_alsa, dep_gl, dep_glew, dep_ogg, dep_png, dep_sdl2, dep_sdl2_ttf,
dep_tcl, dep_theora, dep_threads, dep_vorbis, dep_zlib
],
)
test('combined unit test', test_exec)