|
@@ -292,12 +292,12 @@ endif ()
|
|
|
if (EMSCRIPTEN) # CMAKE_CROSSCOMPILING is always true for Emscripten
|
|
if (EMSCRIPTEN) # CMAKE_CROSSCOMPILING is always true for Emscripten
|
|
|
set (EMSCRIPTEN_ROOT_PATH "" CACHE PATH "Root path to Emscripten cross-compiler tools (Emscripten only)")
|
|
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)")
|
|
set (EMSCRIPTEN_SYSROOT "" CACHE PATH "Path to Emscripten system root (Emscripten only)")
|
|
|
- option (EMSCRIPTEN_ALLOW_MEMORY_GROWTH "Enable memory growing based on application demand (Emscripten only)")
|
|
|
|
|
- math (EXPR EMSCRIPTEN_TOTAL_MEMORY "128 * 1024 * 1024") # This option is ignored when EMSCRIPTEN_ALLOW_MEMORY_GROWTH option is set
|
|
|
|
|
- set (EMSCRIPTEN_TOTAL_MEMORY ${EMSCRIPTEN_TOTAL_MEMORY} CACHE STRING "Specify the total size of memory to be used (Emscripten only); default to 128 MB, this option is ignored when EMSCRIPTEN_ALLOW_MEMORY_GROWTH=1")
|
|
|
|
|
|
|
+ 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_ALLOW_MEMORY_GROWTH "Enable memory growing based on application demand when targeting asm.js, it is not set by default due to performance penalty (Emscripten only)" FALSE "NOT EMSCRIPTEN_WASM" TRUE) # Allo memory growth by default when targeting WebAssembly since there is no performance penalty as in asm.js mode
|
|
|
|
|
+ math (EXPR EMSCRIPTEN_TOTAL_MEMORY "128 * 1024 * 1024")
|
|
|
|
|
+ set (EMSCRIPTEN_TOTAL_MEMORY ${EMSCRIPTEN_TOTAL_MEMORY} CACHE STRING "Specify the total size of memory to be used (Emscripten only); default to 128 MB, must be in multiple of 64 KB when targeting WebAssembly and in multiple of 16 MB when targeting asm.js")
|
|
|
option (EMSCRIPTEN_SHARE_DATA "Enable sharing data file support (Emscripten only)")
|
|
option (EMSCRIPTEN_SHARE_DATA "Enable sharing data file support (Emscripten only)")
|
|
|
cmake_dependent_option (EMSCRIPTEN_SHARE_JS "Share the same JS file responsible to load the shared data file (Emscripten only and when enabling sharing data file support only)" FALSE EMSCRIPTEN_SHARE_DATA FALSE)
|
|
cmake_dependent_option (EMSCRIPTEN_SHARE_JS "Share the same JS file responsible to load the shared data file (Emscripten only and when enabling sharing data file support only)" FALSE EMSCRIPTEN_SHARE_DATA FALSE)
|
|
|
- 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)
|
|
|
|
|
endif ()
|
|
endif ()
|
|
|
# Constrain the build option values in cmake-gui, if applicable
|
|
# Constrain the build option values in cmake-gui, if applicable
|
|
|
set_property (CACHE URHO3D_LIB_TYPE PROPERTY STRINGS STATIC SHARED)
|
|
set_property (CACHE URHO3D_LIB_TYPE PROPERTY STRINGS STATIC SHARED)
|
|
@@ -629,15 +629,15 @@ else ()
|
|
|
set (CMAKE_C_FLAGS_RELEASE "-Oz -DNDEBUG")
|
|
set (CMAKE_C_FLAGS_RELEASE "-Oz -DNDEBUG")
|
|
|
set (CMAKE_CXX_FLAGS_RELEASE "-Oz -DNDEBUG")
|
|
set (CMAKE_CXX_FLAGS_RELEASE "-Oz -DNDEBUG")
|
|
|
# Linker flags
|
|
# Linker flags
|
|
|
- if (EMSCRIPTEN_ALLOW_MEMORY_GROWTH)
|
|
|
|
|
- set (MEMORY_LINKER_FLAGS "-s ALLOW_MEMORY_GROWTH=1")
|
|
|
|
|
- else ()
|
|
|
|
|
- set (MEMORY_LINKER_FLAGS "-s TOTAL_MEMORY=${EMSCRIPTEN_TOTAL_MEMORY}")
|
|
|
|
|
- endif ()
|
|
|
|
|
if (EMSCRIPTEN_WASM)
|
|
if (EMSCRIPTEN_WASM)
|
|
|
- set (WASM "-s WASM=1")
|
|
|
|
|
|
|
+ # Allow emitting of code that might trap (for higher performance)
|
|
|
|
|
+ set (WASM_LINKER_FLAGS "-s WASM=1 -s BINARYEN_IMPRECISE=1") # TODO: BINARYEN_IMPRECISE could be renamed to BINARYEN_EMIT_POTENTIAL_TRAPS or something like that in the coming release)
|
|
|
|
|
+ endif ()
|
|
|
|
|
+ set (MEMORY_LINKER_FLAGS "-s TOTAL_MEMORY=${EMSCRIPTEN_TOTAL_MEMORY}")
|
|
|
|
|
+ if (EMSCRIPTEN_ALLOW_MEMORY_GROWTH)
|
|
|
|
|
+ set (MEMORY_LINKER_FLAGS "${MEMORY_LINKER_FLAGS} -s ALLOW_MEMORY_GROWTH=1")
|
|
|
endif ()
|
|
endif ()
|
|
|
- set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${MEMORY_LINKER_FLAGS} -s NO_EXIT_RUNTIME=1 -s ERROR_ON_UNDEFINED_SYMBOLS=1 ${WASM}")
|
|
|
|
|
|
|
+ set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${WASM_LINKER_FLAGS} ${MEMORY_LINKER_FLAGS} -s NO_EXIT_RUNTIME=1 -s ERROR_ON_UNDEFINED_SYMBOLS=1")
|
|
|
set (CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -O3 -s AGGRESSIVE_VARIABLE_ELIMINATION=1") # Remove variables to make the -O3 regalloc easier
|
|
set (CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -O3 -s AGGRESSIVE_VARIABLE_ELIMINATION=1") # Remove variables to make the -O3 regalloc easier
|
|
|
set (CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -g4") # Preserve LLVM debug information, show line number debug comments, and generate source maps
|
|
set (CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -g4") # Preserve LLVM debug information, show line number debug comments, and generate source maps
|
|
|
if (URHO3D_TESTING)
|
|
if (URHO3D_TESTING)
|