CMake + SDL2 + Emscripten Sample
C/C++ Icon
SDL Icon
Emscripten Icon

CMake + SDL2 + Emscripten Sample

A sample skeleton game project made for indie game developers to use as a reference for integrating CMake, SDL2, and Emscripten together.

View the full source code (MIT license) over on the cmake-testing-grounds repository.

If you're looking for guidance on how to build a cross-platform C++ game for both the web and desktop, this project is for you! It illustrates a modern (2025) CMake build script, and C++ bootstrapping using Emscripten. It includes SDL_image for loading textures, SDL_ttf for loading fonts, and SDL_mixer for loading and playing music and sound effects.

SDL version 2 was chosen because SDL_mixer did not yet have a version 3 release tag at the time this project was created. A separate project targeting SDL3 will be available once the full SDL stack has an official version 3 release!