From dfab34e4bf508fc517d4d645ebb3b6b1179a5003 Mon Sep 17 00:00:00 2001 From: Anders Leino Date: Fri, 11 Oct 2024 13:13:04 +0300 Subject: Add slang-wasm target (#5237) Support for exceptions is enabled, since Slang uses them for diagnostics. The size optimization arguments ('-Os') resolves some internal emscripten error during the slang-wasm.wasm linking step, which happens when enabling exceptions. ("parse exception: too many locals") --- CMakeLists.txt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index b505cbf53..da22ec19a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -371,6 +371,22 @@ if(SLANG_ENABLE_SLANGC) ) endif() +# +# WebAssembly bindings for Slang +# +# This is an executable target because emcmake produces .a files without bindings if you just create a static library +# https://stackoverflow.com/questions/63622009/static-library-built-with-cmake-as-a-with-emscripten-instead-of-wasm-js +slang_add_target( + source/slang-wasm + EXECUTABLE + EXCLUDE_FROM_ALL + USE_FEWER_WARNINGS + LINK_WITH_PRIVATE miniz lz4_static slang core compiler-core + INCLUDE_DIRECTORIES_PUBLIC include source/slang-wasm +) +# To generate binding code +target_link_options(slang-wasm PUBLIC "--bind") + # # Our wrappers for glslang and llvm # -- cgit v1.2.3