# WebAssembly (Emscripten) toolchain hook. # # Used by the `wasm` configure preset to chain-load the real Emscripten # toolchain from the active EMSDK. Phase 0 builds only the hello-world target # in wasm/ (Rule R5 — never blocks shipping). Phase 2 will compile the full # engine (PDFium + Skia + FreeType + HarfBuzz) through this same toolchain. if(NOT DEFINED ENV{EMSDK}) message(FATAL_ERROR "WASM build requested but EMSDK is not set in the environment.\n" "Install and activate the Emscripten SDK:\n" " git clone https://github.com/emscripten-core/emsdk\n" " ./emsdk install latest && ./emsdk activate latest\n" " source ./emsdk_env.sh (or emsdk_env.bat on Windows)\n" "Then re-run: cmake --preset wasm") endif() set(_emscripten_toolchain "$ENV{EMSDK}/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake") if(NOT EXISTS "${_emscripten_toolchain}") message(FATAL_ERROR "Emscripten toolchain not found at: ${_emscripten_toolchain}") endif() include("${_emscripten_toolchain}") # Engine blueprint §6.3: large PDFs can exceed the default WASM heap. set(CMAKE_EXE_LINKER_FLAGS_INIT "-sALLOW_MEMORY_GROWTH=1")