diff --git a/cmake/platforms/emscripten.cmake b/cmake/platforms/emscripten.cmake index 5673ebe..6526037 100644 --- a/cmake/platforms/emscripten.cmake +++ b/cmake/platforms/emscripten.cmake @@ -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)