Build System and Dependency Management¶
This project uses CMake for build automation and dependency management. To facilitate development in atomic OS environments (like Bazzite/Fedora Silverblue), it is designed to run within a Distrobox container.
Build Requirements¶
- CMake 3.14 or higher
- Clang or GCC (C99 support)
- Python 3 (required by GLAD for code generation)
- GLFW 3 (system library)
- Pkg-config
Distrobox Integration¶
The project is optimized for a container named clang-dev. A Makefile wrapper is provided to automatically route commands through distrobox.
Common Commands¶
make: Configures and builds the project inside the container.make debug: Builds with dynamic shaders (Dev mode).make release: Builds with optimized static shaders (Production mode).make run: Builds and executes the application (Debug).make run-release: Builds and executes the application (Release).make rebuild: Performs a clean build from scratch (useful when dependencies change).make format: Formats all C source and header files using clang-format.make lint: Performs static analysis across the codebase using clang-tidy (Guaranteed 0 warnings).make docs: Builds MkDocs + Doxygen documentation.make clean-all: Nukes thebuild/directory.
Offline Build Support¶
For development without an internet connection, you can cache dependencies locally.
1. Preparation (Online)¶
Run the following command while you have an active internet connection:
This script will clonecglm, glad, stb, unity, cjson into a local deps/ directory (automatically ignored by Git).
2. Building (Offline)¶
Once the deps/ directory is populated, CMake will automatically detect it and use the local sources instead of trying to download them. Simply run:
To remove the local cache, use make deps-clean.
3. Testing the Offline Mode¶
To verify that the build truly doesn't reach the network, you can run it in a simulated offline environment:
Note: This command setshttp_proxy to a non-existent local address to block network access. This method is used instead of unshare -rn to ensure compatibility with Distrobox/Podman.
Dependency Management¶
Dependencies are automatically managed via CMake's FetchContent module. No manual installation or management of deps/ is required.
cglm (OpenGL Mathematics for C)¶
- Source: recp/cglm
- Configuration: Built as a static library (
CGLM_STATIC=ON). - Automation: Fetched at configuration time.
GLAD (OpenGL Loader Generator)¶
- Source: Dav1dde/glad
- Configuration: Programmatically generates headers and source for OpenGL 4.4 Core.
- Automation: The generator script is fetched and executed during the CMake configuration phase.
GLFW¶
- Source: System library.
- Automation: Located using
pkg-config. Ensureglfw-devel(or equivalent) is installed in your development container.
Unity¶
- Source: ThrowTheSwitch/Unity
- Automation: Fetched at configuration time.
cJSON¶
- Source: DaveGamble/cJSON
- Automation: Fetched at configuration time.
Security Hardening¶
The project enforces strict security flags during compilation to mitigate memory corruption vulnerabilities:
- Stack Protection:
-fstack-protector-strongadds stack canaries to detect buffer overflows. - Format Security:
-Wformat -Wformat-securityprevents format string attacks. - Fortify Source:
_FORTIFY_SOURCE=2adds runtime checks for common string/memory functions. - Linker Hardening: RELRO, NOW, and NoExecStack are enabled to protect the GOT and prevent stack execution.
Fast Parallel Builds¶
The build is optimized for speed using parallel compilation:
# Via the Makefile wrapper
make all # Executes cmake --build build --parallel
# Directly via CMake
cmake --build build -j$(nproc)
Logging System¶
The application uses a structured logging system to facilitate development and monitoring.
- INFO Level: Asset loading, GPU info, user state changes.
- ERROR Level: Shader compilation failures, allocation errors, window creation failure.
- WARN Level: Detects non-critical anomalies.
Format: 2026-01-13 10:05:10,133 - module - LEVEL - message
Automated Dependencies¶
Thanks to FetchContent, the following libraries are managed without manual intervention:
- cglm: Compiled as a static library optimized for your CPU.
- GLAD: Generated on the fly to target exactly the OpenGL 4.4 Core profile.
- stb_image: Automation via FetchContent. The implementation is isolated in
src/stb_image_impl.cto guarantee perfectly clean linting on the remaining source files. - unity: Automation via FetchContent.
- cjson: Automation via FetchContent.
Folder Structure¶
CMakeLists.txt: Core of the build system.Makefile: Shortcuts for Docker/Distrobox and fast builds.docs/: Full engine documentation.src/log.c: Core of the logging system.assets/: Folder containing assets.assets/env.hdr: Source environment texture (Equirectangular).deps/: Folder containing external dependencies.