summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorAnders Leino <aleino@nvidia.com>2024-10-11 13:13:04 +0300
committerGitHub <noreply@github.com>2024-10-11 18:13:04 +0800
commitdfab34e4bf508fc517d4d645ebb3b6b1179a5003 (patch)
tree0a75a9618ffdbd0604145cade8dbaff7b2af01cd /CMakeLists.txt
parent5fa35fcce532267a2ae5779dee9ff4d07fab6bf4 (diff)
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")
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt16
1 files changed, 16 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b505cbf53..da22ec19a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -372,6 +372,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
#
if(SLANG_ENABLE_SLANG_GLSLANG)