XMLGameEngine

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

View the Project on GitHub beefviper/XMLGameEngine

35. Library and front ends

Status: built (CMakeLists.txt, scripts/cmake/executables.cmake, cli/, gui/)

Decision

The engine is a library, the XGELIB target, in lib/. Everything that loads, runs, draws and tests a game is in it. What was in main.cpp and cli.cpp (read the arguments, find the game file, build Game and Engine, run the loop) moved to cli/ and is a program of its own, XGECLI. A second program, XGEGUI, started as a stub that returned at once; it is now the Qt application (38). The test suite links the library too, so it no longer compiles the engine’s files a second time.

A new front end is now a main() and a few lines in executables.cmake; none of the engine changes.

Static or shared

With two small programs from one repository that are always built together, nothing is gained from sharing, so static is the default. -DXGE_BUILD_SHARED=ON builds a shared library instead, with no source changes: on Windows it exports every symbol (WINDOWS_EXPORT_ALL_SYMBOLS) rather than marking each class by hand, and puts the DLL beside the programs. The tests were run both ways.

Options considered

Approximations

When this was written XGEGUI linked the library but used nothing from it. cli/include is not in the library’s include path, only XGECLI sees it. The run was checked with the window backends replaced by a stub, because the sandbox that built it has no SFML, raylib or SDL2 libraries: configure, build, link and the whole test suite passed for both the static and the shared library, but XGECLI has not been run against a real window from this layout.