annotate OrthancFramework/Resources/CMake/EmscriptenParameters.cmake @ 5651:c4e33e0f907b

merge
author Alain Mazy <am@orthanc.team>
date Wed, 05 Jun 2024 11:04:37 +0200
parents f7adfb22e20e
children
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
5640
f7adfb22e20e updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5485
diff changeset
4 # Copyright (C) 2017-2023 Osimis S.A., Belgium
f7adfb22e20e updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5485
diff changeset
5 # Copyright (C) 2024-2024 Orthanc Team SRL, Belgium
5485
48b8dae6dc77 upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
6 # Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
4120
304842a0d152 adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4075
diff changeset
7 #
304842a0d152 adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4075
diff changeset
8 # 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
9 # 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
10 # 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
11 # the License, or (at your option) any later version.
304842a0d152 adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4075
diff changeset
12 #
304842a0d152 adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4075
diff changeset
13 # 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
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
304842a0d152 adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4075
diff changeset
15 # 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
16 # Lesser General Public License for more details.
304842a0d152 adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4075
diff changeset
17 #
304842a0d152 adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4075
diff changeset
18 # 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
19 # License along with this program. If not, see
304842a0d152 adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4075
diff changeset
20 # <http://www.gnu.org/licenses/>.
304842a0d152 adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4075
diff changeset
21
304842a0d152 adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4075
diff changeset
22
4075
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4070
diff changeset
23 # https://github.com/emscripten-core/emscripten/blob/master/src/settings.js
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4070
diff changeset
24
4063
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 if (NOT "${EMSCRIPTEN_TRAP_MODE}" STREQUAL "")
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 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
27 endif()
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28
4949
49bd6504f15e fix builds on recent versions of emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4870
diff changeset
29 # 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
30 # 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
31 # 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
32 # (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
33 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
34
4075
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4070
diff changeset
35 # "DISABLE_EXCEPTION_CATCHING" is a "compile+link" option. HOWEVER,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4070
diff changeset
36 # setting it inside "WASM_FLAGS" creates link errors, at least with
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4070
diff changeset
37 # side modules. TODO: Understand why
4069
cf454aabfc19 improving EmscriptenParameters.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4067
diff changeset
38 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
39
49bd6504f15e fix builds on recent versions of emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4870
diff changeset
40 # "-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
41 # 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
42 # required for earlier versions of emsdk:
49bd6504f15e fix builds on recent versions of emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4870
diff changeset
43 # 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
44 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
45
4075
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4070
diff changeset
46 #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
47
4063
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 if (EMSCRIPTEN_TARGET_MODE STREQUAL "wasm")
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 # WebAssembly
4070
f1e82dd6acb1 fixed emscripten options
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4069
diff changeset
50 set(WASM_FLAGS "${WASM_FLAGS} -s WASM=1")
4063
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 elseif (EMSCRIPTEN_TARGET_MODE STREQUAL "asm.js")
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 # asm.js targeting IE 11
4070
f1e82dd6acb1 fixed emscripten options
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4069
diff changeset
54 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
55
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 else()
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 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
58 endif()
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 if (CMAKE_BUILD_TYPE STREQUAL "Debug")
4069
cf454aabfc19 improving EmscriptenParameters.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4067
diff changeset
61 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
62 endif()
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WASM_FLAGS}")
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WASM_FLAGS}")