From cd0c08dc7ce754473178ad3f32f7740a1dddc1eb Mon Sep 17 00:00:00 2001 From: Vaino Kauppila Date: Thu, 2 Jul 2026 22:58:25 +0300 Subject: Initial import: LibreForts (M0-M5 in progress) Open-source Forts clone: custom C++20 engine + data-driven (Lua) 2D physics artillery RTS. - Building: node/strut graph on a stiff mass-spring solver (canon Forts model), triangulation rigidity, axial + 30-degree angle-stress breaking, cascading collapse, fire (DoT + spread), ground destroys debris. - Weapons (M4): cannon (ballistic) + laser (beam/ignite) with select-and-aim-in- arc UX; splash / beam damage; bg-brace passthrough. - Devices + economy (M5): reactors + win/loss + restart, mines/turbines/battery, metal deposits, storage caps, per-shot energy cost. - Data-driven via Lua/sol2 with a layered mod loader; enemy-fort scenario mod. - Renderer: SDL3 + textures + ImGui dev UI. stb_image + ImGui vendored. - Assets: CC0 placeholders only; real game art loaded at runtime from the user's own install via forts: paths (bring-your-own; nothing copyrighted committed). See README.md / CLAUDE.md and research/ + requirements/ for detail. --- meson.build | 141 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 141 insertions(+) create mode 100644 meson.build (limited to 'meson.build') diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..0f528a2 --- /dev/null +++ b/meson.build @@ -0,0 +1,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 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, +) -- cgit v1.3