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
|
project('forts-clone', 'cpp',
version: '0.1.0',
license: 'GPL-3.0-or-later',
default_options: [
'cpp_std=c++20',
'warning_level=3',
'buildtype=debugoptimized',
'default_library=static',
],
meson_version: '>=1.4.0',
)
cpp = meson.get_compiler('cpp')
# =============================================================================
# Dependencies (pre-built in /usr/local by Containerfile)
# =============================================================================
# SDL3 -- windowing + input (system package)
sdl3_dep = dependency('sdl3', required: true)
# bgfx -- GPU rendering (built from source in Containerfile)
# CMake on Fedora installs to lib64
bgfx_dep = cpp.find_library('bgfx', dirs: ['/usr/local/lib64', '/usr/local/lib'])
bimg_dep = cpp.find_library('bimg', dirs: ['/usr/local/lib64', '/usr/local/lib'])
bx_dep = cpp.find_library('bx', dirs: ['/usr/local/lib64', '/usr/local/lib'])
# Box2D v3 -- physics engine (built from source in Containerfile)
box2d_dep = cpp.find_library('box2d', dirs: ['/usr/local/lib64', '/usr/local/lib'])
# SoLoud -- audio engine (built from source in Containerfile)
soloud_dep = cpp.find_library('soloud', dirs: ['/usr/local/lib64', '/usr/local/lib'])
# ENet -- networking (built from source in Containerfile)
enet_dep = cpp.find_library('enet', dirs: ['/usr/local/lib/static', '/usr/local/lib64', '/usr/local/lib'])
# IMPORTANT: only add /usr/local/include, NOT /usr/local/include/bx etc.
# as individual paths. sys/types.h does #include <endian.h> and would
# collide with bx/endian.h if -I/usr/local/include/bx is in the path.
local_inc = include_directories('/usr/local/include')
# Lua -- scripting. Linked STATICALLY from /usr/local/lib/liblua.a (built in the
# Containerfile) so the binary needs no liblua .so at runtime and runs on the
# host regardless of its distro's lua soname. Headers come from /usr/local/include.
lua_static = cpp.find_library('lua', dirs: ['/usr/local/lib'], static: true, required: true)
m_dep = cpp.find_library('m', required: false)
dl_dep = cpp.find_library('dl', required: false)
lua_dep = declare_dependency(dependencies: [lua_static, m_dep, dl_dep])
# glm -- math (system package)
glm_dep = dependency('glm', required: true)
# sol2 -- Lua C++ bindings (header-only, installed to /usr/local/include)
sol2_dep = declare_dependency(include_directories: '/usr/local/include')
# EnTT -- ECS (header-only, installed to /usr/local/include)
entt_dep = declare_dependency(include_directories: '/usr/local/include')
# ImGui -- skipped for M0, added when debug UI is needed
# =============================================================================
# Engine library and executable
# =============================================================================
engine_inc = include_directories('src')
stb_inc = include_directories('third_party/stb')
# Dear ImGui (dev UI) — built as its own lib with relaxed warnings.
imgui_inc = include_directories('third_party/imgui', 'third_party/imgui/backends')
imgui_lib = static_library('imgui',
[
'third_party/imgui/imgui.cpp',
'third_party/imgui/imgui_draw.cpp',
'third_party/imgui/imgui_tables.cpp',
'third_party/imgui/imgui_widgets.cpp',
'third_party/imgui/backends/imgui_impl_sdl3.cpp',
'third_party/imgui/backends/imgui_impl_sdlrenderer3.cpp',
],
include_directories: imgui_inc,
dependencies: sdl3_dep,
override_options: ['warning_level=0', 'werror=false'],
)
imgui_dep = declare_dependency(link_with: imgui_lib, include_directories: imgui_inc)
engine_src = [
'src/engine/app.cpp',
'src/engine/renderer.cpp',
'src/engine/input.cpp',
'src/engine/camera.cpp',
'src/engine/physics.cpp',
'src/engine/script.cpp',
'src/engine/stb_impl.cpp',
'src/game/build_graph.cpp',
'src/game/data.cpp',
]
engine_deps = [
sdl3_dep,
bgfx_dep, bimg_dep, bx_dep,
box2d_dep,
soloud_dep,
enet_dep,
lua_dep,
glm_dep,
sol2_dep,
entt_dep,
imgui_dep,
]
extra_inc = [local_inc, stb_inc]
# Required by bx/bgfx (normally set by cmake targets; we need them manually
# since we link raw .a files).
# GCC 14+ on glibc: __BEGIN_DECLS from sys/types.h wraps bx endian.inl
# templates in extern "C". -fpermissive downgrades to warnings.
buildtype = get_option('buildtype')
bx_debug = buildtype.startswith('debug') ? '1' : '0'
extra_cpp_args = [
'-msse4.2',
'-DBX_CONFIG_DEBUG=@0@'.format(bx_debug),
'-DBGFX_CONFIG_DEBUG_ANNOTATION=@0@'.format(bx_debug),
'-DBGFX_CONFIG_MULTITHREADED=1',
'-DBGFX_CONFIG_VIDEO=1',
'-D__STDC_LIMIT_MACROS',
'-D__STDC_FORMAT_MACROS',
'-D__STDC_CONSTANT_MACROS',
]
engine_lib = static_library('engine', engine_src,
include_directories: [engine_inc] + extra_inc,
dependencies: engine_deps,
cpp_args: extra_cpp_args,
)
executable('forts-clone', 'src/main.cpp',
link_with: engine_lib,
include_directories: [engine_inc] + extra_inc,
dependencies: engine_deps,
cpp_args: extra_cpp_args,
)
|