WASM C++ & CMake Template

September 2021

Demo. I released this Github Template to set up a new repo that had full support for running C++ on the web via WASM, using Emscripten, alongside all the required libraries, integrations, best practices, and build systems with CI/CD

A template for using emscripten with C++20 and CMake, and using GLAD and SDL2

  • Emscripten web build, deployed to gh-pages. View demo here
  • Linux, Mac, and Windows native builds via Github Actions
  • Code coverage via CodeCov
  • Code formatting via clang-format
  • Static Analysis using cppcheck and clang-tidy
  • Dynamic Analysis using Address Sanitizer, Leak Sanitizer, Thread Sanitizer, and Undefined Behaviour Sanitizer
  • Unit tests ran using Valgrind for runtime memory analysis
  • Caching builds via ccache
  • Caching CMake dependencies via CPM
  • Multi-project (Monorepo) setup, with MyLib for e.g. a game engine, and MyApp for e.g the gameplay code
  • Unit tests via Doctest
  • Benchmarks via Google Benchmark
  • Strict compiler warnings due to cmake/CompilerWarnings, taken from cpp_starter_project
  • No third-party warnings due to cmake/SetSystemIncludes and cmake/CompilerWarnings
  • Building SDL2 from source