diff Resources/CMake/Compiler.cmake @ 2510:04873915beaf

configuration of DCMTK for WebAssembly
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 28 Mar 2018 14:14:37 +0200
parents 808fd5218f56
children 13038d638097
line wrap: on
line diff
--- a/Resources/CMake/Compiler.cmake	Wed Mar 28 11:31:19 2018 +0200
+++ b/Resources/CMake/Compiler.cmake	Wed Mar 28 14:14:37 2018 +0200
@@ -174,6 +174,12 @@
 elseif (CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
   message("Building using Emscripten (for WebAssembly or asm.js targets)")
 
+  # The BINARYEN_TRAP_MODE specifies what to do when divisions per
+  # zero (and similar conditions like integer overflows) are
+  # encountered: The "clamp" mode avoids throwing errors, as they
+  # cannot be properly catched by "try {} catch (...)" constructions.
+  set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s EXTRA_EXPORTED_RUNTIME_METHODS='[\"ccall\", \"cwrap\"]' -s BINARYEN_TRAP_MODE='\"clamp\"'")
+
 else()
   message(FATAL_ERROR "Support your platform here")
 endif()