Mercurial > hg > orthanc-stone
annotate Applications/Samples/WebAssembly/CMakeLists.txt @ 1978:95449b0e064a
pixel probe is working
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Sat, 29 Oct 2022 16:56:16 +0200 |
parents | 3f88c239043a |
children | a05b03f45289 07964689cb0b |
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 |
1871
7053b8a0aaec
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1870
diff
changeset
|
4 # Copyright (C) 2017-2022 Osimis S.A., Belgium |
7053b8a0aaec
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1870
diff
changeset
|
5 # Copyright (C) 2021-2022 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 | |
1549
a48ae10857b1
packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
48 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
|
49 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
|
50 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
|
51 set(WASM_LINKER_FLAGS "${WASM_LINKER_FLAGS} -s DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1") |
1464 | 52 add_definitions( |
53 -DDISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1 | |
54 ) | |
55 | |
1549
a48ae10857b1
packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
56 |
1464 | 57 # Stone of Orthanc configuration |
58 # --------------------------------------------------------------- | |
59 set(ALLOW_DOWNLOADS ON) | |
60 | |
1902 | 61 include(${CMAKE_SOURCE_DIR}/../../../OrthancStone/Resources/CMake/OrthancStoneWebAssemblyParameters.cmake) |
1464 | 62 |
1474
d1dde1f86d4a
fix build of wasm samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1471
diff
changeset
|
63 SET(ENABLE_DCMTK OFF) # Not necessary |
1464 | 64 SET(ENABLE_GOOGLE_TEST OFF) |
65 SET(ENABLE_LOCALE ON) # Necessary for text rendering | |
66 SET(ORTHANC_SANDBOXED ON) | |
67 | |
1471
28c64c246312
working on a shared library
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1465
diff
changeset
|
68 # 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
|
69 # populate the ORTHANC_STONE_SOURCES CMake variable |
1902 | 70 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
|
71 |
1464 | 72 |
73 # We embed a font to be used for on-screen overlays | |
74 # --------------------------------------------------------------- | |
75 | |
76 DownloadPackage( | |
77 "a24b8136b8f3bb93f166baf97d9328de" | |
78 "http://orthanc.osimis.io/ThirdPartyDownloads/ubuntu-font-family-0.83.zip" | |
79 "${CMAKE_BINARY_DIR}/ubuntu-font-family-0.83") | |
80 | |
1471
28c64c246312
working on a shared library
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1465
diff
changeset
|
81 EmbedResources( |
1586 | 82 COLORMAP_HOT ${CMAKE_SOURCE_DIR}/../../Resources/Colormaps/hot.lut |
1464 | 83 UBUNTU_FONT ${CMAKE_BINARY_DIR}/ubuntu-font-family-0.83/Ubuntu-R.ttf |
84 ) | |
85 | |
86 add_library(OrthancStone STATIC | |
87 ${ORTHANC_STONE_SOURCES} | |
1471
28c64c246312
working on a shared library
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1465
diff
changeset
|
88 ${AUTOGENERATED_SOURCES} |
1464 | 89 ) |
90 | |
91 ################################################################################ | |
92 | |
93 # Define the WASM module | |
94 # --------------------------------------------------------------- | |
95 | |
96 project(RtViewerWasm) | |
97 | |
98 add_executable(RtViewerWasm | |
99 RtViewer/RtViewerWasm.cpp | |
100 ../Common/RtViewerApp.cpp | |
101 ../Common/RtViewerApp.h | |
102 ../Common/RtViewerView.cpp | |
103 ../Common/RtViewerView.h | |
104 ) | |
105 | |
1549
a48ae10857b1
packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
106 set_target_properties(RtViewerWasm |
a48ae10857b1
packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
107 PROPERTIES |
a48ae10857b1
packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
108 COMPILE_FLAGS "${WASM_FLAGS}" |
a48ae10857b1
packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
109 LINK_FLAGS "${WASM_LINKER_FLAGS}" |
a48ae10857b1
packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
110 ) |
a48ae10857b1
packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
111 |
1464 | 112 target_link_libraries(RtViewerWasm OrthancStone) |
113 | |
114 # Declare installation files for the module | |
115 # --------------------------------------------------------------- | |
116 install( | |
117 TARGETS RtViewerWasm | |
1548
65eccce95882
unifying the default install prefix for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1542
diff
changeset
|
118 RUNTIME DESTINATION ${ORTHANC_STONE_INSTALL_PREFIX}/RtViewer/ |
1464 | 119 ) |
120 | |
121 # Declare installation files for the companion files (web scaffolding) | |
122 # please note that ${CMAKE_CURRENT_BINARY_DIR}/RtViewerWasm.js | |
123 # (the generated JS loader for the WASM module) is handled by the `install1` | |
124 # section above: it is considered to be the binary output of | |
125 # the linker. | |
126 # --------------------------------------------------------------- | |
127 install( | |
128 FILES | |
129 ${CMAKE_SOURCE_DIR}/RtViewer/RtViewerWasmApp.js | |
130 ${CMAKE_SOURCE_DIR}/RtViewer/index.html | |
131 ${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
|
132 DESTINATION ${ORTHANC_STONE_INSTALL_PREFIX}/RtViewer/ |
1464 | 133 ) |
134 | |
135 ################################################################################ | |
136 | |
137 # Define the WASM module | |
138 # --------------------------------------------------------------- | |
139 | |
140 project(SingleFrameViewerWasm) | |
141 | |
142 add_executable(SingleFrameViewerWasm | |
143 SingleFrameViewer/SingleFrameViewer.cpp | |
144 ) | |
145 | |
1549
a48ae10857b1
packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
146 set_target_properties(SingleFrameViewerWasm |
a48ae10857b1
packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
147 PROPERTIES |
a48ae10857b1
packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
148 COMPILE_FLAGS "${WASM_FLAGS}" |
a48ae10857b1
packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
149 LINK_FLAGS "${WASM_LINKER_FLAGS}" |
a48ae10857b1
packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
150 ) |
a48ae10857b1
packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
151 |
1464 | 152 target_link_libraries(SingleFrameViewerWasm OrthancStone) |
153 | |
154 # Declare installation files for the module | |
155 # --------------------------------------------------------------- | |
156 install( | |
157 TARGETS SingleFrameViewerWasm | |
1548
65eccce95882
unifying the default install prefix for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1542
diff
changeset
|
158 RUNTIME DESTINATION ${ORTHANC_STONE_INSTALL_PREFIX}/SingleFrameViewer/ |
1464 | 159 ) |
160 | |
161 # Declare installation files for the companion files (web scaffolding) | |
162 # please note that ${CMAKE_CURRENT_BINARY_DIR}/RtViewerWasm.js | |
163 # (the generated JS loader for the WASM module) is handled by the `install1` | |
164 # section above: it is considered to be the binary output of | |
165 # the linker. | |
166 # --------------------------------------------------------------- | |
167 install( | |
168 FILES | |
169 ${CMAKE_SOURCE_DIR}/SingleFrameViewer/SingleFrameViewerApp.js | |
170 ${CMAKE_SOURCE_DIR}/SingleFrameViewer/index.html | |
171 ${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
|
172 DESTINATION ${ORTHANC_STONE_INSTALL_PREFIX}/SingleFrameViewer/ |
1464 | 173 ) |