Mercurial > hg > orthanc-stone
annotate Applications/Samples/WebAssembly/CMakeLists.txt @ 2123:538c7b7c6e46 deep-learning
integration mainline->deep-learning
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 22 Mar 2024 16:11:42 +0100 |
parents | de049fd88697 |
children | 2e050ec85379 |
rev | line source |
---|---|
1589
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1586
diff
changeset
|
1 # Stone of Orthanc |
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1586
diff
changeset
|
2 # Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1586
diff
changeset
|
3 # Department, University Hospital of Liege, Belgium |
2114
c23eef785569
update year to 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2111
diff
changeset
|
4 # Copyright (C) 2017-2024 Osimis S.A., Belgium |
c23eef785569
update year to 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2111
diff
changeset
|
5 # Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
1589
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1586
diff
changeset
|
6 # |
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1586
diff
changeset
|
7 # This program is free software: you can redistribute it and/or |
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1586
diff
changeset
|
8 # modify it under the terms of the GNU Affero General Public License |
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1586
diff
changeset
|
9 # as published by the Free Software Foundation, either version 3 of |
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1586
diff
changeset
|
10 # the License, or (at your option) any later version. |
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1586
diff
changeset
|
11 # |
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1586
diff
changeset
|
12 # This program is distributed in the hope that it will be useful, but |
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1586
diff
changeset
|
13 # WITHOUT ANY WARRANTY; without even the implied warranty of |
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1586
diff
changeset
|
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1586
diff
changeset
|
15 # Affero General Public License for more details. |
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1586
diff
changeset
|
16 # |
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1586
diff
changeset
|
17 # You should have received a copy of the GNU Affero General Public License |
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1586
diff
changeset
|
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1586
diff
changeset
|
19 |
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1586
diff
changeset
|
20 |
1464 | 21 cmake_minimum_required(VERSION 2.8.3) |
1592 | 22 cmake_policy(SET CMP0058 NEW) |
1464 | 23 |
24 project(OrthancStone) | |
25 | |
1735
2bb735d76726
fix CMake for wasm samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1666
diff
changeset
|
26 set(SAMPLES_VERSION "mainline") |
2bb735d76726
fix CMake for wasm samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1666
diff
changeset
|
27 |
2bb735d76726
fix CMake for wasm samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1666
diff
changeset
|
28 if (SAMPLES_VERSION STREQUAL "mainline") |
2bb735d76726
fix CMake for wasm samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1666
diff
changeset
|
29 set(ORTHANC_FRAMEWORK_DEFAULT_VERSION "mainline") |
2bb735d76726
fix CMake for wasm samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1666
diff
changeset
|
30 set(ORTHANC_FRAMEWORK_DEFAULT_SOURCE "hg") |
2bb735d76726
fix CMake for wasm samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1666
diff
changeset
|
31 else() |
1957 | 32 set(ORTHANC_FRAMEWORK_DEFAULT_VERSION "1.11.2") |
1735
2bb735d76726
fix CMake for wasm samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1666
diff
changeset
|
33 set(ORTHANC_FRAMEWORK_DEFAULT_SOURCE "web") |
2bb735d76726
fix CMake for wasm samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1666
diff
changeset
|
34 endif() |
2bb735d76726
fix CMake for wasm samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1666
diff
changeset
|
35 |
1548
65eccce95882
unifying the default install prefix for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1542
diff
changeset
|
36 set(ORTHANC_STONE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}/../../../wasm-binaries/" CACHE PATH "Where to put the WebAssembly binaries") |
65eccce95882
unifying the default install prefix for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1542
diff
changeset
|
37 |
65eccce95882
unifying the default install prefix for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1542
diff
changeset
|
38 |
1464 | 39 # Configuration of the Emscripten compiler for WebAssembly target |
40 # --------------------------------------------------------------- | |
41 set(USE_WASM ON CACHE BOOL "") | |
42 | |
1666
1e6d3289b1ad
enable catching of exceptions in stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
43 set(WASM_FLAGS "-s WASM=1 -s FETCH=1 -s ASSERTIONS=1 -s DISABLE_EXCEPTION_CATCHING=0") |
1464 | 44 if (CMAKE_BUILD_TYPE STREQUAL "Debug") |
45 set(WASM_FLAGS "${WASM_FLAGS} -s SAFE_HEAP=1") | |
46 endif() | |
47 | |
2048
a05b03f45289
added ORTHANC_WEBGL2_HEAP_COMPAT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1957
diff
changeset
|
48 set(WASM_LINKER_FLAGS "${WASM_LINKER_FLAGS} -s ENVIRONMENT=web") |
2081
3ef91da06636
fix compatibility with Emscripten 3.1.47
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2077
diff
changeset
|
49 set(WASM_LINKER_FLAGS "${WASM_LINKER_FLAGS} -s EXPORTED_RUNTIME_METHODS='[\"ccall\", \"cwrap\"]'") |
1549
a48ae10857b1
packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
50 set(WASM_LINKER_FLAGS "${WASM_LINKER_FLAGS} -s ERROR_ON_UNDEFINED_SYMBOLS=1") |
a48ae10857b1
packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
51 set(WASM_LINKER_FLAGS "${WASM_LINKER_FLAGS} -s ALLOW_MEMORY_GROWTH=1 -s TOTAL_MEMORY=268435456") # 256MB + resize |
a48ae10857b1
packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
52 set(WASM_LINKER_FLAGS "${WASM_LINKER_FLAGS} -s DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1") |
1464 | 53 add_definitions( |
54 -DDISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1 | |
2069
5956d7357098
macro ORTHANC_HAS_WASM_SIMD has to be manually defined
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
55 -DORTHANC_HAS_WASM_SIMD=0 |
2048
a05b03f45289
added ORTHANC_WEBGL2_HEAP_COMPAT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1957
diff
changeset
|
56 -DORTHANC_WEBGL2_HEAP_COMPAT=0 |
1464 | 57 ) |
58 | |
1549
a48ae10857b1
packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
59 |
1464 | 60 # Stone of Orthanc configuration |
61 # --------------------------------------------------------------- | |
62 set(ALLOW_DOWNLOADS ON) | |
63 | |
1902 | 64 include(${CMAKE_SOURCE_DIR}/../../../OrthancStone/Resources/CMake/OrthancStoneWebAssemblyParameters.cmake) |
1464 | 65 |
1474
d1dde1f86d4a
fix build of wasm samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1471
diff
changeset
|
66 SET(ENABLE_DCMTK OFF) # Not necessary |
1464 | 67 SET(ENABLE_GOOGLE_TEST OFF) |
68 SET(ENABLE_LOCALE ON) # Necessary for text rendering | |
2081
3ef91da06636
fix compatibility with Emscripten 3.1.47
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2077
diff
changeset
|
69 SET(ENABLE_MODULE_JOBS OFF) |
1464 | 70 SET(ORTHANC_SANDBOXED ON) |
71 | |
1471
28c64c246312
working on a shared library
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1465
diff
changeset
|
72 # this will set up the build system for Stone of Orthanc and will |
28c64c246312
working on a shared library
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1465
diff
changeset
|
73 # populate the ORTHANC_STONE_SOURCES CMake variable |
1902 | 74 include(${CMAKE_SOURCE_DIR}/../../../OrthancStone/Resources/CMake/OrthancStoneWebAssemblyConfiguration.cmake) |
1471
28c64c246312
working on a shared library
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1465
diff
changeset
|
75 |
1464 | 76 |
77 # We embed a font to be used for on-screen overlays | |
78 # --------------------------------------------------------------- | |
79 | |
80 DownloadPackage( | |
81 "a24b8136b8f3bb93f166baf97d9328de" | |
2111
f8f80e432abc
third party downloads from uclouvain servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2110
diff
changeset
|
82 "https://orthanc.uclouvain.be/downloads/third-party-downloads/ubuntu-font-family-0.83.zip" |
1464 | 83 "${CMAKE_BINARY_DIR}/ubuntu-font-family-0.83") |
84 | |
1471
28c64c246312
working on a shared library
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1465
diff
changeset
|
85 EmbedResources( |
1586 | 86 COLORMAP_HOT ${CMAKE_SOURCE_DIR}/../../Resources/Colormaps/hot.lut |
1464 | 87 UBUNTU_FONT ${CMAKE_BINARY_DIR}/ubuntu-font-family-0.83/Ubuntu-R.ttf |
88 ) | |
89 | |
90 add_library(OrthancStone STATIC | |
91 ${ORTHANC_STONE_SOURCES} | |
1471
28c64c246312
working on a shared library
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1465
diff
changeset
|
92 ${AUTOGENERATED_SOURCES} |
1464 | 93 ) |
94 | |
2110
352cb0fa57b2
fixed handling of DefineSourceBasenameForTarget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2081
diff
changeset
|
95 if (COMMAND DefineSourceBasenameForTarget) |
352cb0fa57b2
fixed handling of DefineSourceBasenameForTarget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2081
diff
changeset
|
96 DefineSourceBasenameForTarget(OrthancStone) |
352cb0fa57b2
fixed handling of DefineSourceBasenameForTarget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2081
diff
changeset
|
97 endif() |
2081
3ef91da06636
fix compatibility with Emscripten 3.1.47
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2077
diff
changeset
|
98 |
3ef91da06636
fix compatibility with Emscripten 3.1.47
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2077
diff
changeset
|
99 |
1464 | 100 ################################################################################ |
101 | |
102 # Define the WASM module | |
103 # --------------------------------------------------------------- | |
104 | |
105 project(RtViewerWasm) | |
106 | |
107 add_executable(RtViewerWasm | |
108 RtViewer/RtViewerWasm.cpp | |
109 ../Common/RtViewerApp.cpp | |
110 ../Common/RtViewerApp.h | |
111 ../Common/RtViewerView.cpp | |
112 ../Common/RtViewerView.h | |
113 ) | |
114 | |
2110
352cb0fa57b2
fixed handling of DefineSourceBasenameForTarget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2081
diff
changeset
|
115 if (COMMAND DefineSourceBasenameForTarget) |
352cb0fa57b2
fixed handling of DefineSourceBasenameForTarget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2081
diff
changeset
|
116 DefineSourceBasenameForTarget(RtViewerWasm) |
352cb0fa57b2
fixed handling of DefineSourceBasenameForTarget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2081
diff
changeset
|
117 endif() |
2081
3ef91da06636
fix compatibility with Emscripten 3.1.47
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2077
diff
changeset
|
118 |
1549
a48ae10857b1
packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
119 set_target_properties(RtViewerWasm |
a48ae10857b1
packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
120 PROPERTIES |
a48ae10857b1
packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
121 COMPILE_FLAGS "${WASM_FLAGS}" |
a48ae10857b1
packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
122 LINK_FLAGS "${WASM_LINKER_FLAGS}" |
a48ae10857b1
packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
123 ) |
a48ae10857b1
packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
124 |
1464 | 125 target_link_libraries(RtViewerWasm OrthancStone) |
126 | |
127 # Declare installation files for the module | |
128 # --------------------------------------------------------------- | |
129 install( | |
130 TARGETS RtViewerWasm | |
1548
65eccce95882
unifying the default install prefix for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1542
diff
changeset
|
131 RUNTIME DESTINATION ${ORTHANC_STONE_INSTALL_PREFIX}/RtViewer/ |
1464 | 132 ) |
133 | |
134 # Declare installation files for the companion files (web scaffolding) | |
135 # please note that ${CMAKE_CURRENT_BINARY_DIR}/RtViewerWasm.js | |
136 # (the generated JS loader for the WASM module) is handled by the `install1` | |
137 # section above: it is considered to be the binary output of | |
138 # the linker. | |
139 # --------------------------------------------------------------- | |
140 install( | |
141 FILES | |
142 ${CMAKE_SOURCE_DIR}/RtViewer/RtViewerWasmApp.js | |
143 ${CMAKE_SOURCE_DIR}/RtViewer/index.html | |
144 ${CMAKE_CURRENT_BINARY_DIR}/RtViewerWasm.wasm | |
1548
65eccce95882
unifying the default install prefix for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1542
diff
changeset
|
145 DESTINATION ${ORTHANC_STONE_INSTALL_PREFIX}/RtViewer/ |
1464 | 146 ) |
147 | |
148 ################################################################################ | |
149 | |
150 # Define the WASM module | |
151 # --------------------------------------------------------------- | |
152 | |
153 project(SingleFrameViewerWasm) | |
154 | |
155 add_executable(SingleFrameViewerWasm | |
156 SingleFrameViewer/SingleFrameViewer.cpp | |
157 ) | |
158 | |
2110
352cb0fa57b2
fixed handling of DefineSourceBasenameForTarget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2081
diff
changeset
|
159 if (COMMAND DefineSourceBasenameForTarget) |
352cb0fa57b2
fixed handling of DefineSourceBasenameForTarget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2081
diff
changeset
|
160 DefineSourceBasenameForTarget(SingleFrameViewerWasm) |
352cb0fa57b2
fixed handling of DefineSourceBasenameForTarget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2081
diff
changeset
|
161 endif() |
2081
3ef91da06636
fix compatibility with Emscripten 3.1.47
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2077
diff
changeset
|
162 |
1549
a48ae10857b1
packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
163 set_target_properties(SingleFrameViewerWasm |
a48ae10857b1
packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
164 PROPERTIES |
a48ae10857b1
packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
165 COMPILE_FLAGS "${WASM_FLAGS}" |
a48ae10857b1
packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
166 LINK_FLAGS "${WASM_LINKER_FLAGS}" |
a48ae10857b1
packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
167 ) |
a48ae10857b1
packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
168 |
1464 | 169 target_link_libraries(SingleFrameViewerWasm OrthancStone) |
170 | |
171 # Declare installation files for the module | |
172 # --------------------------------------------------------------- | |
173 install( | |
174 TARGETS SingleFrameViewerWasm | |
1548
65eccce95882
unifying the default install prefix for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1542
diff
changeset
|
175 RUNTIME DESTINATION ${ORTHANC_STONE_INSTALL_PREFIX}/SingleFrameViewer/ |
1464 | 176 ) |
177 | |
178 # Declare installation files for the companion files (web scaffolding) | |
179 # please note that ${CMAKE_CURRENT_BINARY_DIR}/RtViewerWasm.js | |
180 # (the generated JS loader for the WASM module) is handled by the `install1` | |
181 # section above: it is considered to be the binary output of | |
182 # the linker. | |
183 # --------------------------------------------------------------- | |
184 install( | |
185 FILES | |
186 ${CMAKE_SOURCE_DIR}/SingleFrameViewer/SingleFrameViewerApp.js | |
187 ${CMAKE_SOURCE_DIR}/SingleFrameViewer/index.html | |
188 ${CMAKE_CURRENT_BINARY_DIR}/SingleFrameViewerWasm.wasm | |
1548
65eccce95882
unifying the default install prefix for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1542
diff
changeset
|
189 DESTINATION ${ORTHANC_STONE_INSTALL_PREFIX}/SingleFrameViewer/ |
1464 | 190 ) |
2081
3ef91da06636
fix compatibility with Emscripten 3.1.47
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2077
diff
changeset
|
191 |
3ef91da06636
fix compatibility with Emscripten 3.1.47
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2077
diff
changeset
|
192 |
3ef91da06636
fix compatibility with Emscripten 3.1.47
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2077
diff
changeset
|
193 # Boost::Math begs for -std=c++14 since Boost 1.82.0 |
3ef91da06636
fix compatibility with Emscripten 3.1.47
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2077
diff
changeset
|
194 set_property(TARGET OrthancStone PROPERTY CXX_STANDARD 14) |
3ef91da06636
fix compatibility with Emscripten 3.1.47
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2077
diff
changeset
|
195 set_property(TARGET RtViewerWasm PROPERTY CXX_STANDARD 14) |
3ef91da06636
fix compatibility with Emscripten 3.1.47
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2077
diff
changeset
|
196 set_property(TARGET SingleFrameViewerWasm PROPERTY CXX_STANDARD 14) |
3ef91da06636
fix compatibility with Emscripten 3.1.47
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2077
diff
changeset
|
197 |