XMLGameEngine

An engine for describing games built around Xerces, exprtk, and SFML.

View the Project on GitHub beefviper/XMLGameEngine

18. Build system

Status: implemented

Decision

One top-level CMakeLists.txt, with the logic split into modules in scripts/cmake/ (assets, dependencies, executables, options, platform, targets, tests). Source, include and assets directories stay clean; there is no CMakeLists.txt in every directory. The XGELIB target is a library and executables.cmake defines the programs built on it (35).

The alternative proposed first was a CMakeLists.txt in each subdirectory (main, source, data). The author preferred a single root file plus a cmake/ (or scripts/cmake/) directory.

How the modules behave

A .cmake file included from the main file runs immediately. A file can both run some code at once and define functions the main file calls later, when it wants control of timing. Repeated logic was factored into per-file helper macros and functions.

Dependencies

A build gotcha worth remembering

On Windows, when SFML is fetched from GitHub but finds FreeType through vcpkg, a malformed optimized/debug entry can show up in FreeType’s INTERFACE_LINK_LIBRARIES. It is a leftover of CMake’s older keyword convention and is not a valid path. The fix used is a small guarded loop that strips those keywords (right where it is consumed, so it survives dependency updates). An untried alternative: set(CMAKE_DISABLE_FIND_PACKAGE_Freetype TRUE) so SFML builds its own FreeType.

Other notes

Second batch: alternatives

Sources