2026-05-16 11:01:20 +05:30
|
|
|
# WebAssembly (Emscripten) toolchain hook.
|
2026-05-15 10:39:16 +05:30
|
|
|
#
|
2026-05-16 11:01:20 +05:30
|
|
|
# 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.
|
2026-05-15 10:39:16 +05:30
|
|
|
|
|
|
|
|
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")
|