Cmake project to demonstrate the compilation of C++ sources to Webassembly + js
- Cmake: Simply download and install following the instructions here
- Emscripten SDK: just
git clone [email protected]:emscripten-core/emsdk.git
cd emsdk
./emsdk install latest
- locate the
Emscripten.cmake
in your emsdk source folder (should be/path/to/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake
) - create a build folder and cd into it
cd /path/to/cpp2js
mkdir build
cd build
Notice: the build will not export the main
- build with
cmake -DCMAKE_TOOLCHAIN_FILE=<path_to>/Emscripten.cmake -DCMAKE_BUILD_TYPE=Release
cmake --build -- -j8
- serve
/path/to/cpp2js
with your favorite web server
Notice: a main function is provided for ease of testing and debugging. A suitable cpp compiler (gcc, clang) is required
cmake -DCMAKE_BUILD_TYPE=Debug
cmake --build -- -j8