annotate OrthancStone/Resources/Orthanc/CMake/EmscriptenParameters.cmake @ 2008:37d6805b80ee deep-learning

integration mainline->deep-learning
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 18 Nov 2022 00:37:00 +0100
parents f4cdcba8c32a
children 07964689cb0b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1549
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 # Orthanc - A Lightweight, RESTful DICOM Store
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 # Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 # Department, University Hospital of Liege, Belgium
1871
7053b8a0aaec upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1869
diff changeset
4 # Copyright (C) 2017-2022 Osimis S.A., Belgium
7053b8a0aaec upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1869
diff changeset
5 # Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
1549
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 #
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 # This program is free software: you can redistribute it and/or
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 # modify it under the terms of the GNU Lesser General Public License
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 # as published by the Free Software Foundation, either version 3 of
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 # the License, or (at your option) any later version.
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 #
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 # This program is distributed in the hope that it will be useful, but
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 # Lesser General Public License for more details.
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 #
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 # You should have received a copy of the GNU Lesser General Public
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 # License along with this program. If not, see
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 # <http://www.gnu.org/licenses/>.
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 # https://github.com/emscripten-core/emscripten/blob/master/src/settings.js
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 if (NOT "${EMSCRIPTEN_TRAP_MODE}" STREQUAL "")
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s BINARYEN_TRAP_MODE='\"${EMSCRIPTEN_TRAP_MODE}\"'")
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 endif()
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27
1918
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1917
diff changeset
28 # If "-O3" is used (the default in "Release" mode), this results in a
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1917
diff changeset
29 # too large memory consumption in "wasm-opt", at least in Emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1917
diff changeset
30 # 3.1.7, which ultimately crashes the compiler. So we force "-O2"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1917
diff changeset
31 # (this also has the advantage of speeding up the build):
1923
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1918
diff changeset
32 set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
1918
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1917
diff changeset
33
1549
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 # "DISABLE_EXCEPTION_CATCHING" is a "compile+link" option. HOWEVER,
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 # setting it inside "WASM_FLAGS" creates link errors, at least with
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 # side modules. TODO: Understand why
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s DISABLE_EXCEPTION_CATCHING=0")
1917
9c52c0376ad7 improved definition of -Wno-unused-command-line-argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1871
diff changeset
38
9c52c0376ad7 improved definition of -Wno-unused-command-line-argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1871
diff changeset
39 # "-Wno-unused-command-line-argument" is used to avoid annoying
9c52c0376ad7 improved definition of -Wno-unused-command-line-argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1871
diff changeset
40 # warnings about setting WASM, FETCH and ASSERTIONS, which was
9c52c0376ad7 improved definition of -Wno-unused-command-line-argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1871
diff changeset
41 # required for earlier versions of emsdk:
9c52c0376ad7 improved definition of -Wno-unused-command-line-argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1871
diff changeset
42 # https://groups.google.com/g/emscripten-discuss/c/VX4enWfadUE
9c52c0376ad7 improved definition of -Wno-unused-command-line-argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1871
diff changeset
43 set(WASM_FLAGS "${WASM_FLAGS} -Wno-unused-command-line-argument")
9c52c0376ad7 improved definition of -Wno-unused-command-line-argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1871
diff changeset
44
1549
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 #set(WASM_FLAGS "${WASM_FLAGS} -s DISABLE_EXCEPTION_CATCHING=0")
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 if (EMSCRIPTEN_TARGET_MODE STREQUAL "wasm")
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 # WebAssembly
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 set(WASM_FLAGS "${WASM_FLAGS} -s WASM=1")
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 elseif (EMSCRIPTEN_TARGET_MODE STREQUAL "asm.js")
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 # asm.js targeting IE 11
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 set(WASM_FLAGS "-s WASM=0 -s ASM_JS=2 -s LEGACY_VM_SUPPORT=1")
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 else()
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 message(FATAL_ERROR "Bad value for EMSCRIPTEN_TARGET_MODE: ${EMSCRIPTEN_TARGET_MODE}")
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 endif()
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 if (CMAKE_BUILD_TYPE STREQUAL "Debug")
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 set(WASM_FLAGS "${WASM_FLAGS} -s SAFE_HEAP=1 -s ASSERTIONS=1")
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 endif()
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WASM_FLAGS}")
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WASM_FLAGS}")