aboutsummaryrefslogtreecommitdiffstats
path: root/meson.build
diff options
context:
space:
mode:
authorEmil A. Overbeck <emil.a.overbeck@gmail.com>2026-07-17 23:48:17 +0200
committerEmil A. Overbeck <emil.a.overbeck@gmail.com>2026-07-17 23:48:17 +0200
commit655ec946e63fcf2234f67a837cc7602099b6c301 (patch)
treefe017792cb6053b54dad13ea776cc61b193e2bfe /meson.build
parent716cd9cf495835dc3a1bb0045e64f3f954cf3a62 (diff)
downloadforts_clone-655ec946e63fcf2234f67a837cc7602099b6c301.tar.gz
forts_clone-655ec946e63fcf2234f67a837cc7602099b6c301.zip
Better Steam path detection and build guide
Diffstat (limited to 'meson.build')
-rw-r--r--meson.build100
1 files changed, 63 insertions, 37 deletions
diff --git a/meson.build b/meson.build
index 0f528a2..e063136 100644
--- a/meson.build
+++ b/meson.build
@@ -16,45 +16,75 @@ 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'])
+fs = import('fs')
-# Box2D v3 -- physics engine (built from source in Containerfile)
-box2d_dep = cpp.find_library('box2d', dirs: ['/usr/local/lib64', '/usr/local/lib'])
+# A source-built /usr/local (what the container ships) provides the heavier
+# libraries. On a stock system these paths are absent, so everything below falls
+# back to system packages. include_directories() errors on a missing directory,
+# hence the guard.
+#
+# NOTE: add /usr/local/include as a whole, never /usr/local/include/bx etc.
+# individually. sys/types.h includes <endian.h>, which collides with bx's
+# endian.h if -I.../include/bx is on the path.
+local_incs = []
+if fs.is_dir('/usr/local/include')
+ local_incs += include_directories('/usr/local/include')
+endif
+usr_local_libdirs = ['/usr/local/lib64', '/usr/local/lib', '/usr/local/lib/static']
-# SoLoud -- audio engine (built from source in Containerfile)
-soloud_dep = cpp.find_library('soloud', dirs: ['/usr/local/lib64', '/usr/local/lib'])
+# --- Libraries the code actually compiles against ---------------------------
-# ENet -- networking (built from source in Containerfile)
-enet_dep = cpp.find_library('enet', dirs: ['/usr/local/lib/static', '/usr/local/lib64', '/usr/local/lib'])
+# SDL3 -- windowing + input. System pkg-config on every target.
+sdl3_dep = dependency('sdl3', required: true)
-# 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')
+# glm -- header-only math. pkg-config where available, else rely on the include
+# path (headers in /usr/include or the guarded /usr/local/include).
+glm_dep = dependency('glm', required: false)
+if not glm_dep.found()
+ glm_dep = declare_dependency()
+endif
-# 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])
+# sol2 -- header-only Lua bindings. Headers resolve via the include path
+# (/usr/include/sol system/AUR, or /usr/local/include/sol in the container).
+sol2_dep = declare_dependency()
-# glm -- math (system package)
-glm_dep = dependency('glm', required: true)
+# Lua 5.4. Container: a STATIC liblua.a in /usr/local/lib, so the binary carries
+# Lua and runs on any host regardless of its liblua soname. Native build: the
+# system Lua 5.4 (dynamic linking is fine when built and run on the same box).
+lua_static = cpp.find_library('lua', dirs: ['/usr/local/lib'], static: true, required: false)
+if lua_static.found()
+ 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])
+else
+ lua_dep = dependency('lua5.4', 'lua54', 'lua-5.4', required: false)
+ if not lua_dep.found()
+ lua_dep = dependency('lua', required: true)
+ endif
+endif
-# sol2 -- Lua C++ bindings (header-only, installed to /usr/local/include)
-sol2_dep = declare_dependency(include_directories: '/usr/local/include')
+# Box2D v3 -- physics. Idle for now, but physics.cpp compiles against its header.
+# Try /usr/local (container), then pkg-config/cmake, then a plain system lib.
+box2d_dep = cpp.find_library('box2d', dirs: usr_local_libdirs, required: false)
+if not box2d_dep.found()
+ box2d_dep = dependency('box2d', required: false)
+endif
+if not box2d_dep.found()
+ box2d_dep = cpp.find_library('box2d', required: true)
+endif
-# EnTT -- ECS (header-only, installed to /usr/local/include)
-entt_dep = declare_dependency(include_directories: '/usr/local/include')
+# --- Declared but not yet wired up ------------------------------------------
+# bgfx/SoLoud/ENet/EnTT belong to the planned stack, but no source file
+# #includes them yet (the live renderer is SDL_Renderer; physics/audio/net are
+# idle). Link them only if a source build has provided them; a stock system
+# build simply skips them. Promote each to a real dependency when it is wired up.
+optional_deps = []
+foreach libname : ['bgfx', 'bimg', 'bx', 'soloud', 'enet']
+ found = cpp.find_library(libname, dirs: usr_local_libdirs, required: false)
+ if found.found()
+ optional_deps += found
+ endif
+endforeach
# ImGui -- skipped for M0, added when debug UI is needed
@@ -96,18 +126,14 @@ engine_src = [
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,
-]
+] + optional_deps
-extra_inc = [local_inc, stb_inc]
+extra_inc = local_incs + [stb_inc]
# Required by bx/bgfx (normally set by cmake targets; we need them manually
# since we link raw .a files).