|
|
@@ -332,7 +332,7 @@ if (EMSCRIPTEN) # CMAKE_CROSSCOMPILING is always true for Emscripten
|
|
|
set (MODULE MODULE)
|
|
|
set (EMSCRIPTEN_ROOT_PATH "" CACHE PATH "Root path to Emscripten cross-compiler tools (Emscripten only)")
|
|
|
set (EMSCRIPTEN_SYSROOT "" CACHE PATH "Path to Emscripten system root (Emscripten only)")
|
|
|
- cmake_dependent_option (EMSCRIPTEN_WASM "Enable Binaryen support to generate output to WASM (WebAssembly) format (Emscripten only)" FALSE "NOT EMSCRIPTEN_EMCC_VERSION VERSION_LESS 1.37.3" FALSE)
|
|
|
+ cmake_dependent_option (EMSCRIPTEN_WASM "Enable Binaryen support to generate output to WASM (WebAssembly) format (Emscripten only)" TRUE "NOT EMSCRIPTEN_EMCC_VERSION VERSION_LESS 1.37.3" FALSE)
|
|
|
# Currently Emscripten does not support memory growth with MODULE library type
|
|
|
if (URHO3D_LIB_TYPE STREQUAL MODULE)
|
|
|
set (DEFAULT_MEMORY_GROWTH FALSE)
|
|
|
@@ -683,6 +683,12 @@ else ()
|
|
|
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s EXTRA_EXPORTED_RUNTIME_METHODS=\"['Pointer_stringify']\"")
|
|
|
set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -s EXTRA_EXPORTED_RUNTIME_METHODS=\"['Pointer_stringify']\"")
|
|
|
endif ()
|
|
|
+ # Since version 1.37.28 emcc reduces default runtime exports, but we need "FS" so it needs to be explicitly requested now
|
|
|
+ # (See https://github.com/kripken/emscripten/commit/f2191c1223e8261bf45f4e27d2ba4d2e9d8b3341 for more detail)
|
|
|
+ if (NOT EMSCRIPTEN_EMCC_VERSION VERSION_LESS 1.37.28)
|
|
|
+ set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s FORCE_FILESYSTEM=1")
|
|
|
+ set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -s FORCE_FILESYSTEM=1")
|
|
|
+ endif ()
|
|
|
set (CMAKE_C_FLAGS_RELEASE "-Oz -DNDEBUG")
|
|
|
set (CMAKE_CXX_FLAGS_RELEASE "-Oz -DNDEBUG")
|
|
|
# Remove variables to make the -O3 regalloc easier, embed data in asm.js to reduce number of moving part
|
|
|
@@ -1794,6 +1800,10 @@ macro (_setup_target)
|
|
|
list (APPEND LINK_FLAGS "-s NO_EXIT_RUNTIME=1 -s ERROR_ON_UNDEFINED_SYMBOLS=1")
|
|
|
if (EMSCRIPTEN_WASM)
|
|
|
list (APPEND LINK_FLAGS "-s WASM=1")
|
|
|
+ elseif (NOT EMSCRIPTEN_EMCC_VERSION VERSION_LESS 1.38.1)
|
|
|
+ # Since version 1.38.1 emcc emits WASM by default, so we need to explicitily turn it off to emits asm.js
|
|
|
+ # (See https://github.com/kripken/emscripten/commit/6e5818017d1b2e09e9f7ad22a32e9a191f6f9a3b for more detail)
|
|
|
+ list (APPEND LINK_FLAGS "-s WASM=0")
|
|
|
endif ()
|
|
|
endif ()
|
|
|
# Pass EMCC-specifc setting to differentiate between main and side modules
|