Building CNA
Step 1 — Clone and initialise submodules
git clone https://github.com/openeggbert/cna.git
cd cna
git submodule update --init --recursive
This populates third_party/SDL, third_party/SDL_image, and third_party/SDL_mixer. After this step, SDL is built from source by the CMake build — no system SDL packages are required.
Step 2 — Select a backend and build
CNA requires exactly one rendering backend to be selected at configuration time via -DCNA_GRAPHICS_BACKEND=<BACKEND>. Available backends: SDL_RENDERER, EASYGL, BGFX, VULKAN.
Linux — EasyGL (OpenGL) backend
cmake -S . -B build -DCNA_GRAPHICS_BACKEND=EASYGL
cmake --build build --target CNA CnaTests
Requires ../easy-gl to be present alongside the CNA repository.
Linux — SDL_Renderer backend
cmake -S . -B build-sdlrenderer -DCNA_GRAPHICS_BACKEND=SDL_RENDERER
cmake --build build-sdlrenderer --target CNA CnaTests
Windows — SDL_Renderer backend (MSVC)
On Windows with MSVC 2022 opened from a Developer Command Prompt:
git submodule update --init --recursive
cmake -S . -B build-win -DCNA_GRAPHICS_BACKEND=SDL_RENDERER
cmake --build build-win --target CNA CnaTests
Linux → Windows cross-compilation (MinGW-w64)
# Install the cross toolchain (Debian/Ubuntu)
sudo apt install mingw-w64
git submodule update --init --recursive
cmake -S . -B build-windows \
-DCMAKE_TOOLCHAIN_FILE=cmake/toolchains/mingw-w64.cmake \
-DCNA_GRAPHICS_BACKEND=SDL_RENDERER
cmake --build build-windows --target CNA CnaTests
bgfx backend
cmake -S . -B build-bgfx -DCNA_GRAPHICS_BACKEND=BGFX
cmake --build build-bgfx --target CNA
bgfx is fetched via CMake FetchContent — no separate clone needed. Implementation is ongoing; not all features are complete.
Vulkan backend (stub)
cmake -S . -B build-vulkan -DCNA_GRAPHICS_BACKEND=VULKAN
cmake --build build-vulkan --target CNA
The Vulkan backend is an architecture scaffold. Implementation is incomplete and contains stub areas.
Optional: use system-installed SDL
By default CNA builds SDL3 from the vendored submodules. If you prefer to link against system SDL3 packages, pass -DCNA_USE_SYSTEM_SDL=ON:
cmake -S . -B build -DCNA_USE_SYSTEM_SDL=ON -DCNA_GRAPHICS_BACKEND=SDL_RENDERER
cmake --build build --target CNA CnaTests
This calls find_package for SDL3, SDL3_image, and SDL3_mixer. The packages must be installed (e.g. via your distribution's package manager).
Running the tests
ctest --test-dir build --output-on-failure
Running the demos
# Hello-triangle verification target
cmake --build build --target hello-triangle-sdl
# 3D cube demo (if present)
cmake --build build --target cna_cube3d_demo
./build/cna_cube3d_demo
Tested compiler matrix
| Platform | Compiler | Backend | Status |
|---|---|---|---|
| Linux x86_64 | GCC 12+ | EASYGL, SDL_RENDERER | Tested |
| Linux x86_64 | Clang 15+ | EASYGL, SDL_RENDERER | Tested |
| Windows x86_64 | MSVC 2022 | SDL_RENDERER | Planned |
| Windows x86_64 | MinGW-w64 | SDL_RENDERER | Planned |
| Linux → Windows | MinGW-w64 (cross) | SDL_RENDERER | Planned |
CMake options reference
| Option | Values | Default | Description |
|---|---|---|---|
CNA_GRAPHICS_BACKEND | SDL_RENDERER, EASYGL, BGFX, VULKAN | SDL_RENDERER | Selects the rendering backend for this build. |
CNA_USE_SYSTEM_SDL | ON, OFF | OFF | Link against system SDL3 packages instead of vendored submodules. |
Troubleshooting
sharp-runtime not found
CNA requires sharp-runtime to be present as a sibling directory:
parent/
├── cna/
└── sharp-runtime/
Clone sharp-runtime next to CNA and re-run CMake configuration.
easy-gl not found (EASYGL backend)
The EASYGL backend requires easy-gl as a sibling directory. Clone it alongside CNA or switch to SDL_RENDERER if you do not need OpenGL.
Submodule directories empty
Run git submodule update --init --recursive from the repository root. If this fails, check your network and that the submodule URLs in .gitmodules are accessible.