Mercurial > hg > orthanc-stone
annotate Applications/Samples/WebAssembly/CMakeLists.txt @ 1731:816e1634f221 StoneWebViewer-1.0
StoneWebViewer-1.0
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 02 Dec 2020 13:19:15 +0100 |
parents | 1e6d3289b1ad |
children | 2bb735d76726 |
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 |
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1586
diff
changeset
|
4 # Copyright (C) 2017-2020 Osimis S.A., Belgium |
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1586
diff
changeset
|
5 # |
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1586
diff
changeset
|
6 # 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
|
7 # 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
|
8 # 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
|
9 # the License, or (at your option) any later version. |
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1586
diff
changeset
|
10 # |
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1586
diff
changeset
|
11 # 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
|
12 # WITHOUT ANY WARRANTY; without even the implied warranty of |
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1586
diff
changeset
|
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1586
diff
changeset
|
14 # Affero General Public License for more details. |
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1586
diff
changeset
|
15 # |
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1586
diff
changeset
|
16 # 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
|
17 # 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
|
18 |
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1586
diff
changeset
|
19 |
1464 | 20 cmake_minimum_required(VERSION 2.8.3) |
1592 | 21 cmake_policy(SET CMP0058 NEW) |
1464 | 22 |
23 project(OrthancStone) | |
24 | |
1548
65eccce95882
unifying the default install prefix for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1542
diff
changeset
|
25 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
|
26 |
65eccce95882
unifying the default install prefix for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1542
diff
changeset
|
27 |
1464 | 28 # Configuration of the Emscripten compiler for WebAssembly target |
29 # --------------------------------------------------------------- | |
30 set(USE_WASM ON CACHE BOOL "") | |
31 | |
1666
1e6d3289b1ad
enable catching of exceptions in stone web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1656
diff
changeset
|
32 set(WASM_FLAGS "-s WASM=1 -s FETCH=1 -s ASSERTIONS=1 -s DISABLE_EXCEPTION_CATCHING=0") |
1464 | 33 if (CMAKE_BUILD_TYPE STREQUAL "Debug") |
34 set(WASM_FLAGS "${WASM_FLAGS} -s SAFE_HEAP=1") | |
35 endif() | |
36 | |
1549
a48ae10857b1
packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
37 set(WASM_LINKER_FLAGS "${WASM_LINKER_FLAGS} -s EXTRA_EXPORTED_RUNTIME_METHODS='[\"ccall\", \"cwrap\"]'") |
a48ae10857b1
packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
38 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
|
39 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
|
40 set(WASM_LINKER_FLAGS "${WASM_LINKER_FLAGS} -s DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1") |
1464 | 41 add_definitions( |
42 -DDISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1 | |
43 ) | |
44 | |
1549
a48ae10857b1
packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
45 |
1464 | 46 # Stone of Orthanc configuration |
47 # --------------------------------------------------------------- | |
48 set(ALLOW_DOWNLOADS ON) | |
49 | |
1591
5887a4f8594b
moving platform-specific files out of the "OrthancStone" folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1589
diff
changeset
|
50 include(${CMAKE_SOURCE_DIR}/../../Platforms/WebAssembly/OrthancStoneWebAssemblyParameters.cmake) |
1464 | 51 |
1474
d1dde1f86d4a
fix build of wasm samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1471
diff
changeset
|
52 SET(ENABLE_DCMTK OFF) # Not necessary |
1464 | 53 SET(ENABLE_GOOGLE_TEST OFF) |
54 SET(ENABLE_LOCALE ON) # Necessary for text rendering | |
55 SET(ORTHANC_SANDBOXED ON) | |
56 | |
1471
28c64c246312
working on a shared library
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1465
diff
changeset
|
57 # 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
|
58 # populate the ORTHANC_STONE_SOURCES CMake variable |
1591
5887a4f8594b
moving platform-specific files out of the "OrthancStone" folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1589
diff
changeset
|
59 include(${CMAKE_SOURCE_DIR}/../../Platforms/WebAssembly/OrthancStoneWebAssemblyConfiguration.cmake) |
1471
28c64c246312
working on a shared library
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1465
diff
changeset
|
60 |
1464 | 61 |
62 # We embed a font to be used for on-screen overlays | |
63 # --------------------------------------------------------------- | |
64 | |
65 DownloadPackage( | |
66 "a24b8136b8f3bb93f166baf97d9328de" | |
67 "http://orthanc.osimis.io/ThirdPartyDownloads/ubuntu-font-family-0.83.zip" | |
68 "${CMAKE_BINARY_DIR}/ubuntu-font-family-0.83") | |
69 | |
1471
28c64c246312
working on a shared library
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1465
diff
changeset
|
70 EmbedResources( |
1586 | 71 COLORMAP_HOT ${CMAKE_SOURCE_DIR}/../../Resources/Colormaps/hot.lut |
1464 | 72 UBUNTU_FONT ${CMAKE_BINARY_DIR}/ubuntu-font-family-0.83/Ubuntu-R.ttf |
73 ) | |
74 | |
75 add_library(OrthancStone STATIC | |
76 ${ORTHANC_STONE_SOURCES} | |
1471
28c64c246312
working on a shared library
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1465
diff
changeset
|
77 ${AUTOGENERATED_SOURCES} |
1464 | 78 ) |
79 | |
80 ################################################################################ | |
81 | |
82 # Define the WASM module | |
83 # --------------------------------------------------------------- | |
84 | |
85 project(RtViewerWasm) | |
86 | |
87 add_executable(RtViewerWasm | |
88 RtViewer/RtViewerWasm.cpp | |
89 ../Common/RtViewerApp.cpp | |
90 ../Common/RtViewerApp.h | |
91 ../Common/RtViewerView.cpp | |
92 ../Common/RtViewerView.h | |
93 ) | |
94 | |
1549
a48ae10857b1
packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
95 set_target_properties(RtViewerWasm |
a48ae10857b1
packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
96 PROPERTIES |
a48ae10857b1
packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
97 COMPILE_FLAGS "${WASM_FLAGS}" |
a48ae10857b1
packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
98 LINK_FLAGS "${WASM_LINKER_FLAGS}" |
a48ae10857b1
packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
99 ) |
a48ae10857b1
packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
100 |
1464 | 101 target_link_libraries(RtViewerWasm OrthancStone) |
102 | |
103 # Declare installation files for the module | |
104 # --------------------------------------------------------------- | |
105 install( | |
106 TARGETS RtViewerWasm | |
1548
65eccce95882
unifying the default install prefix for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1542
diff
changeset
|
107 RUNTIME DESTINATION ${ORTHANC_STONE_INSTALL_PREFIX}/RtViewer/ |
1464 | 108 ) |
109 | |
110 # Declare installation files for the companion files (web scaffolding) | |
111 # please note that ${CMAKE_CURRENT_BINARY_DIR}/RtViewerWasm.js | |
112 # (the generated JS loader for the WASM module) is handled by the `install1` | |
113 # section above: it is considered to be the binary output of | |
114 # the linker. | |
115 # --------------------------------------------------------------- | |
116 install( | |
117 FILES | |
118 ${CMAKE_SOURCE_DIR}/RtViewer/RtViewerWasmApp.js | |
119 ${CMAKE_SOURCE_DIR}/RtViewer/index.html | |
120 ${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
|
121 DESTINATION ${ORTHANC_STONE_INSTALL_PREFIX}/RtViewer/ |
1464 | 122 ) |
123 | |
124 ################################################################################ | |
125 | |
126 # Define the WASM module | |
127 # --------------------------------------------------------------- | |
128 | |
129 project(SingleFrameViewerWasm) | |
130 | |
131 add_executable(SingleFrameViewerWasm | |
132 SingleFrameViewer/SingleFrameViewer.cpp | |
133 ) | |
134 | |
1549
a48ae10857b1
packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
135 set_target_properties(SingleFrameViewerWasm |
a48ae10857b1
packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
136 PROPERTIES |
a48ae10857b1
packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
137 COMPILE_FLAGS "${WASM_FLAGS}" |
a48ae10857b1
packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
138 LINK_FLAGS "${WASM_LINKER_FLAGS}" |
a48ae10857b1
packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
139 ) |
a48ae10857b1
packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
140 |
1464 | 141 target_link_libraries(SingleFrameViewerWasm OrthancStone) |
142 | |
143 # Declare installation files for the module | |
144 # --------------------------------------------------------------- | |
145 install( | |
146 TARGETS SingleFrameViewerWasm | |
1548
65eccce95882
unifying the default install prefix for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1542
diff
changeset
|
147 RUNTIME DESTINATION ${ORTHANC_STONE_INSTALL_PREFIX}/SingleFrameViewer/ |
1464 | 148 ) |
149 | |
150 # Declare installation files for the companion files (web scaffolding) | |
151 # please note that ${CMAKE_CURRENT_BINARY_DIR}/RtViewerWasm.js | |
152 # (the generated JS loader for the WASM module) is handled by the `install1` | |
153 # section above: it is considered to be the binary output of | |
154 # the linker. | |
155 # --------------------------------------------------------------- | |
156 install( | |
157 FILES | |
158 ${CMAKE_SOURCE_DIR}/SingleFrameViewer/SingleFrameViewerApp.js | |
159 ${CMAKE_SOURCE_DIR}/SingleFrameViewer/index.html | |
160 ${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
|
161 DESTINATION ${ORTHANC_STONE_INSTALL_PREFIX}/SingleFrameViewer/ |
1464 | 162 ) |