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.
This commit is contained in:
Ben Harris
2022-10-26 22:49:36 +01:00
parent 6f5debe417
commit 5af0cd4ac1

View File

@ -3,6 +3,9 @@ set(platform_gui_libs)
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 @@ set(CMAKE_C_LINK_FLAGS "\
-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)