diff OrthancFramework/Resources/CMake/EmscriptenParameters.cmake @ 4962:501411a67f10 more-tags

merge
author Alain Mazy <am@osimis.io>
date Wed, 23 Mar 2022 12:23:11 +0100
parents 15ce7af202f1
children 0ea402b4d901
line wrap: on
line diff
--- a/OrthancFramework/Resources/CMake/EmscriptenParameters.cmake	Wed Mar 23 11:56:28 2022 +0100
+++ b/OrthancFramework/Resources/CMake/EmscriptenParameters.cmake	Wed Mar 23 12:23:11 2022 +0100
@@ -25,10 +25,23 @@
   set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s BINARYEN_TRAP_MODE='\"${EMSCRIPTEN_TRAP_MODE}\"'")
 endif()
 
+# If "-O3" is used (the default in "Release" mode), this results in a
+# too large memory consumption in "wasm-opt", at least in Emscripten
+# 3.1.7, which ultimately crashes the compiler. So we force "-O2"
+# (this also has the advantage of speeding up the build):
+set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
+
 # "DISABLE_EXCEPTION_CATCHING" is a "compile+link" option. HOWEVER,
 # setting it inside "WASM_FLAGS" creates link errors, at least with
 # side modules. TODO: Understand why
 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s DISABLE_EXCEPTION_CATCHING=0")
+
+# "-Wno-unused-command-line-argument" is used to avoid annoying
+# warnings about setting WASM, FETCH and ASSERTIONS, which was
+# required for earlier versions of emsdk:
+# https://groups.google.com/g/emscripten-discuss/c/VX4enWfadUE
+set(WASM_FLAGS "${WASM_FLAGS} -Wno-unused-command-line-argument")
+
 #set(WASM_FLAGS "${WASM_FLAGS} -s DISABLE_EXCEPTION_CATCHING=0")
 
 if (EMSCRIPTEN_TARGET_MODE STREQUAL "wasm")