Skip to content

Zephilinox/emscripten-cpp-cmake-template

Repository files navigation

MyLib MyApp codecov GitHub license Website ricardoheath.co.uk/emscripten-cpp-cmake-template/

emscripten-cpp-cmake-template

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

Note: glad and KHR were generated from cmake/FetchGLAD. Unfortunately the GLAD generator doesn't seem to generate gles2 properly when ran on the Github Actions runners, so it was generated locally and commited to the repo instead.

main.cpp of MyApp is from this Gist by SuperV1234, with changes based on static analysis and formatting, and small tweaks to get GLAD and SDL running with gles2 in native builds.

About

A template for using emscripten on the Web, along with native OpenGLES builds. C++20, CMake, GLAD, SDL2, and IMGUI.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published