OXYGENHUB
◆ main openmsx / meson.build
5.3 KiB · NAnt Build File · last changed chore(): initial commit 1 month ago source blame history raw
1
project(
2
    'openMSX', 'cpp',
3
    license: 'GPL-2.0-only',
4
    default_options: ['warning_level=3', 'cpp_std=c++23'],
5
    meson_version: '>=0.50.0'
6
)
7
8
subdir('src')
9
10
# Compile Flags
11
# =============
12
13
compiler = meson.get_compiler('cpp')
14
15
if compiler.get_argument_syntax() == 'gcc'
16
# We support GCC and Clang.
17
18
# Additional warnings:
19
20
add_project_arguments('-Wundef', language: 'cpp')
21
add_project_arguments('-Wshadow', language: 'cpp')
22
add_project_arguments('-Wunused-macros', language: 'cpp')
23
add_project_arguments('-Wdouble-promotion', language: 'cpp')
24
add_project_arguments('-Wmissing-declarations', language: 'cpp')
25
add_project_arguments('-Wold-style-cast', language: 'cpp')
26
add_project_arguments('-Wzero-as-null-pointer-constant', language: 'cpp')
27
28
# Disable warnings that cause too many false positives:
29
30
add_project_arguments('-Wno-pedantic', language: 'cpp')
31
add_project_arguments('-Wno-invalid-offsetof', language: 'cpp')
32
33
# Hardware descriptions can contain constants that are not used in the code
34
# but still useful as documentation.
35
# The flag exists for both GCC and Clang, but GCC doesn't enable it via -Wall.
36
# We'll disable it for both, just in case GCC auto-enables it in the future.
37
add_project_arguments('-Wno-unused-const-variable', language: 'cpp')
38
39
endif
40
41
# Dependencies
42
# ============
43
44
dep_sdl2 = dependency('SDL2')
45
dep_sdl2_ttf = dependency('SDL2_ttf')
46
dep_png = dependency('libpng')
47
dep_tcl = dependency('tcl', version: '>=8.6.0')
48
dep_threads = dependency('threads')
49
dep_zlib = dependency('zlib')
50
51
# The TLS support for the SMXWiFi device loads the host OpenSSL at runtime
52
# (dlopen): that needs an explicit libdl on glibc older than 2.34 (the
53
# library is absent on other systems, in which case it is simply skipped).
54
dep_dl = compiler.find_library('dl', required: false)
55
56
dep_gl = dependency('GL', required: get_option('glrenderer'))
57
dep_glew = dependency('glew', required: get_option('glrenderer'))
58
59
dep_ogg = dependency('ogg', required: get_option('laserdisc'))
60
dep_theora = dependency('theoradec', required: get_option('laserdisc'))
61
dep_vorbis = dependency('vorbis', required: get_option('laserdisc'))
62
63
if host_machine.system() == 'linux'
64
dep_alsa = dependency('alsa', required: get_option('alsamidi'))
65
else
66
dep_alsa = dependency('', required: false)
67
endif
68
69
# Components
70
# ==========
71
72
components = {
73
    'CORE':
74
        true,
75
    'GL':
76
        not get_option('glrenderer').disabled()
77
        and dep_gl.found() and dep_glew.found(),
78
    'LASERDISC':
79
        not get_option('laserdisc').disabled()
80
        and dep_ogg.found() and dep_theora.found() and dep_vorbis.found(),
81
    'ALSAMIDI':
82
        not get_option('alsamidi').disabled()
83
        and dep_alsa.found(),
84
}
85
86
# TODO: Subset the sources.
87
88
conf_components = configuration_data()
89
enabled_components = []
90
foreach name, enabled: components
91
    conf_components.set10('COMPONENT_' + name, enabled)
92
    if enabled
93
        enabled_components += name
94
    endif
95
endforeach
96
conf_components.set(
97
    'BUILD_COMPONENTS', '"' + ' '.join(enabled_components) + '"'
98
)
99
hdr_components = configure_file(
100
    output: 'components.hh',
101
    configuration: conf_components
102
)
103
104
# System Functions
105
# ================
106
107
conf_systemfuncs = configuration_data()
108
conf_systemfuncs.set10(
109
    'HAVE_FTRUNCATE',
110
    compiler.has_function('ftruncate', prefix: '#include <unistd.h>')
111
)
112
if host_machine.system() in ['darwin', 'openbsd']
113
    mmap_prefix = '\n'.join([
114
        '#include <sys/types.h>',
115
        '#include <sys/mman.h>'
116
    ])
117
else
118
    mmap_prefix = '#include <sys/mman.h>'
119
endif
120
conf_systemfuncs.set10(
121
    'HAVE_MMAP',
122
    compiler.has_function('mmap', prefix: mmap_prefix)
123
)
124
hdr_systemfuncs = configure_file(
125
    output: 'systemfuncs.hh',
126
    configuration: conf_systemfuncs
127
)
128
129
# Other Generated Headers
130
# =======================
131
132
prog_python = import('python').find_installation('python3')
133
134
hdr_version = custom_target(
135
    'version header',
136
    output: 'Version.ii',
137
    input: 'build/version2code.py',
138
    command: [prog_python, '@INPUT@', '@OUTPUT@'],
139
    build_always_stale: true,
140
)
141
142
abs_datadir = get_option('prefix') / get_option('datadir') / 'openmsx'
143
144
hdr_config = custom_target(
145
    'build info header',
146
    output: 'build-info.hh',
147
    input: 'build/buildinfo2code.py',
148
    command: [
149
        prog_python, '@INPUT@', '@OUTPUT@',
150
        host_machine.system(),
151
        host_machine.cpu_family(), # TODO: is cpu() more suitable?
152
        'devel', # OPENMSX_FLAVOUR
153
        abs_datadir
154
    ],
155
)
156
157
# Targets
158
# =======
159
160
main_exec = executable(
161
    'openmsx',
162
    main_sources, sources,
163
    hdr_version, hdr_config, hdr_components, hdr_systemfuncs,
164
    install: true,
165
    implicit_include_directories: false,
166
    include_directories: [incdirs, '.'],
167
    dependencies: [
168
        dep_alsa, dep_dl, dep_gl, dep_glew, dep_ogg, dep_png, dep_sdl2, dep_sdl2_ttf,
169
        dep_tcl, dep_theora, dep_threads, dep_vorbis, dep_zlib
170
    ],
171
)
172
173
objects = main_exec.extract_objects(sources)
174
175
test_exec = executable(
176
    'unittest',
177
    test_sources,
178
    hdr_version, hdr_config, hdr_components, hdr_systemfuncs,
179
    objects: objects,
180
    build_by_default: false,
181
    install: false,
182
    implicit_include_directories: false,
183
    include_directories: [incdirs, '.', 'Contrib/catch2'],
184
    dependencies: [
185
        dep_alsa, dep_dl, dep_gl, dep_glew, dep_ogg, dep_png, dep_sdl2, dep_sdl2_ttf,
186
        dep_tcl, dep_theora, dep_threads, dep_vorbis, dep_zlib
187
    ],
188
)
189
190
test('combined unit test', test_exec)