ref: 5af0cd4ac1f906fb09e0bf1cac967c1c27dc240f
parent: 6f5debe417dbcb4b17be00fa4790b80ed887158c
author: Ben Harris <bjh21@bjh21.me.uk>
date: Wed Oct 26 18:49:36 EDT 2022
js: Add a CMake variable to control whether Emscripten emits WASM I've finally got bored of keeping (and occasionally losing) a patch that turns it off unconditionally.
--- a/cmake/platforms/emscripten.cmake
+++ b/cmake/platforms/emscripten.cmake
@@ -3,6 +3,9 @@
set(platform_libs)
set(CMAKE_EXECUTABLE_SUFFIX ".js")
+set(WASM ON
+ CACHE BOOL "Compile to WebAssembly rather than plain JavaScript")
+
set(emcc_export_list
# Event handlers for mouse and keyboard input
_mouseup
@@ -33,6 +36,11 @@
-s ALLOW_MEMORY_GROWTH=1 \
-s EXPORTED_FUNCTIONS='[${emcc_export_string}]' \
-s EXTRA_EXPORTED_RUNTIME_METHODS='[cwrap,callMain]'")
+if(WASM)
+ set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -s WASM=1")
+else()
+ set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -s WASM=0")
+endif()
set(build_cli_programs FALSE)
set(build_gui_programs FALSE)