This project wraps asm-dom and gccx in CMake for easy integration into C++ projects.
This makes it simple to build dynamic single page web apps entirely in C++ (or CPX, JSX-like syntax for C++), using standard CMake and the Emscripten toolchain for WebAssembly, without writing any JavaScript!
This project is similar to and was inspired by asm-dom-cmake, but makes some different design decisions and is ready to be dropped into any new C++ WASM project as a submodule. See cppmart-asmdom as a project integration example.
The button-counter CPX example is taken from asm-dom-cmake with modifications to the build. Live demo.
The todo-mvc CPX example is based on an original example from asm-dom. Live demo.
- Install CMake, Emscripten, and Ninja (or alternatively use Make)
- Install
gccx
through npm (npm typically gets installed with Emscripten) - Git clone recursively (to get the asm-dom submodule) right into your project
- Run
gccx
at build time through CMake and link againstasm-dom
as per the examples
To build the examples
cd cmake-asm-dom-wrapper
mkdir build && cd build
emcmake cmake -G Ninja .. -DBUILD_ASM_DOM_EXAMPLE=1
ninja
Then to run, emrun example/todomvc-cpp/index.html --no_browser
and open http://localhost:6931
in your browser. Alternatively use Python's http.server
.