CMake
How to build a CMake project using Cheerp
CMake projects can be compiled with Cheerp by passing a single additional command-line flag to cmake.
A CMake toolchain files are provided in the $CHEERP/share/cmake/Modules/ directory, where the CHEERP environment variable is set to the path of your Cheerp installation.
For example:
- On Linux:
export CHEERP=/opt/cheerp - On macOS:
export CHEERP=/Applications/cheerp - On Windows:
set CHEERP=C:\cheerp
Compiling to WebAssembly
To compile with -target cheerp-wasm (default, recommended), use CheerpWasmToolchain.cmake.
cmake -DCMAKE_TOOLCHAIN_FILE=$CHEERP/share/cmake/Modules/CheerpWasmToolchain.cmake .Compiling to JavaScript
To compile with -target cheerp, use CheerpToolchain.cmake.
cmake -DCMAKE_TOOLCHAIN_FILE=$CHEERP/share/cmake/Modules/CheerpToolchain.cmake .