annotate OrthancFramework/Resources/CMake/EmscriptenParameters.cmake @ 5271:c5f243ad7103

switch third party downloads to UCLouvain which provides faster network
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 13 Apr 2023 16:39:16 +0200
parents 0ea402b4d901
children 48b8dae6dc77
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4120
304842a0d152 adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4075
diff changeset
1 # Orthanc - A Lightweight, RESTful DICOM Store
304842a0d152 adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4075
diff changeset
2 # Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
304842a0d152 adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4075
diff changeset
3 # Department, University Hospital of Liege, Belgium
5185
0ea402b4d901 upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4952
diff changeset
4 # Copyright (C) 2017-2023 Osimis S.A., Belgium
0ea402b4d901 upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4952
diff changeset
5 # Copyright (C) 2021-2023 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
4120
304842a0d152 adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4075
diff changeset
6 #
304842a0d152 adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4075
diff changeset
7 # This program is free software: you can redistribute it and/or
304842a0d152 adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4075
diff changeset
8 # modify it under the terms of the GNU Lesser General Public License
304842a0d152 adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4075
diff changeset
9 # as published by the Free Software Foundation, either version 3 of
304842a0d152 adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4075
diff changeset
10 # the License, or (at your option) any later version.
304842a0d152 adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4075
diff changeset
11 #
304842a0d152 adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4075
diff changeset
12 # This program is distributed in the hope that it will be useful, but
304842a0d152 adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4075
diff changeset
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
304842a0d152 adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4075
diff changeset
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
304842a0d152 adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4075
diff changeset
15 # Lesser General Public License for more details.
304842a0d152 adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4075
diff changeset
16 #
304842a0d152 adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4075
diff changeset
17 # You should have received a copy of the GNU Lesser General Public
304842a0d152 adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4075
diff changeset
18 # License along with this program. If not, see
304842a0d152 adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4075
diff changeset
19 # <http://www.gnu.org/licenses/>.
304842a0d152 adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4075
diff changeset
20
304842a0d152 adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4075
diff changeset
21
4075
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4070
diff changeset
22 # https://github.com/emscripten-core/emscripten/blob/master/src/settings.js
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4070
diff changeset
23
4063
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 if (NOT "${EMSCRIPTEN_TRAP_MODE}" STREQUAL "")
e00f3d089991 shared library of orthanc framework
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}\"'")
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 endif()
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27
4949
49bd6504f15e fix builds on recent versions of emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4870
diff changeset
28 # If "-O3" is used (the default in "Release" mode), this results in a
49bd6504f15e fix builds on recent versions of emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4870
diff changeset
29 # too large memory consumption in "wasm-opt", at least in Emscripten
49bd6504f15e fix builds on recent versions of emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4870
diff changeset
30 # 3.1.7, which ultimately crashes the compiler. So we force "-O2"
49bd6504f15e fix builds on recent versions of emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4870
diff changeset
31 # (this also has the advantage of speeding up the build):
4952
15ce7af202f1 fix EmscriptenParameters.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4949
diff changeset
32 set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
4949
49bd6504f15e fix builds on recent versions of emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4870
diff changeset
33
4075
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4070
diff changeset
34 # "DISABLE_EXCEPTION_CATCHING" is a "compile+link" option. HOWEVER,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4070
diff changeset
35 # setting it inside "WASM_FLAGS" creates link errors, at least with
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4070
diff changeset
36 # side modules. TODO: Understand why
4069
cf454aabfc19 improving EmscriptenParameters.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4067
diff changeset
37 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s DISABLE_EXCEPTION_CATCHING=0")
4949
49bd6504f15e fix builds on recent versions of emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4870
diff changeset
38
49bd6504f15e fix builds on recent versions of emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4870
diff changeset
39 # "-Wno-unused-command-line-argument" is used to avoid annoying
49bd6504f15e fix builds on recent versions of emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4870
diff changeset
40 # warnings about setting WASM, FETCH and ASSERTIONS, which was
49bd6504f15e fix builds on recent versions of emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4870
diff changeset
41 # required for earlier versions of emsdk:
49bd6504f15e fix builds on recent versions of emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4870
diff changeset
42 # https://groups.google.com/g/emscripten-discuss/c/VX4enWfadUE
49bd6504f15e fix builds on recent versions of emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4870
diff changeset
43 set(WASM_FLAGS "${WASM_FLAGS} -Wno-unused-command-line-argument")
49bd6504f15e fix builds on recent versions of emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4870
diff changeset
44
4075
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4070
diff changeset
45 #set(WASM_FLAGS "${WASM_FLAGS} -s DISABLE_EXCEPTION_CATCHING=0")
4069
cf454aabfc19 improving EmscriptenParameters.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4067
diff changeset
46
4063
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 if (EMSCRIPTEN_TARGET_MODE STREQUAL "wasm")
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 # WebAssembly
4070
f1e82dd6acb1 fixed emscripten options
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4069
diff changeset
49 set(WASM_FLAGS "${WASM_FLAGS} -s WASM=1")
4063
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 elseif (EMSCRIPTEN_TARGET_MODE STREQUAL "asm.js")
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 # asm.js targeting IE 11
4070
f1e82dd6acb1 fixed emscripten options
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4069
diff changeset
53 set(WASM_FLAGS "-s WASM=0 -s ASM_JS=2 -s LEGACY_VM_SUPPORT=1")
4063
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 else()
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 message(FATAL_ERROR "Bad value for EMSCRIPTEN_TARGET_MODE: ${EMSCRIPTEN_TARGET_MODE}")
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 endif()
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 if (CMAKE_BUILD_TYPE STREQUAL "Debug")
4069
cf454aabfc19 improving EmscriptenParameters.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4067
diff changeset
60 set(WASM_FLAGS "${WASM_FLAGS} -s SAFE_HEAP=1 -s ASSERTIONS=1")
4063
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 endif()
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WASM_FLAGS}")
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WASM_FLAGS}")