Mercurial > hg > orthanc-stone
annotate Applications/Samples/WebAssembly/CMakeLists.txt @ 1574:fb5e620430ae
fix
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 21 Sep 2020 18:29:53 +0200 |
parents | a48ae10857b1 |
children | b5417e377636 |
rev | line source |
---|---|
1464 | 1 cmake_minimum_required(VERSION 2.8.3) |
2 | |
3 project(OrthancStone) | |
4 | |
1548
65eccce95882
unifying the default install prefix for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1542
diff
changeset
|
5 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
|
6 |
65eccce95882
unifying the default install prefix for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1542
diff
changeset
|
7 |
1464 | 8 # Configuration of the Emscripten compiler for WebAssembly target |
9 # --------------------------------------------------------------- | |
10 set(USE_WASM ON CACHE BOOL "") | |
11 | |
12 set(EMSCRIPTEN_SET_LLVM_WASM_BACKEND ON CACHE BOOL "") | |
13 | |
14 set(WASM_FLAGS "-s WASM=1 -s FETCH=1") | |
15 if (CMAKE_BUILD_TYPE STREQUAL "Debug") | |
16 set(WASM_FLAGS "${WASM_FLAGS} -s SAFE_HEAP=1") | |
17 endif() | |
18 | |
1549
a48ae10857b1
packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
19 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
|
20 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
|
21 set(WASM_LINKER_FLAGS "${WASM_LINKER_FLAGS} -s ASSERTIONS=1 -s DISABLE_EXCEPTION_CATCHING=0") |
a48ae10857b1
packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
22 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
|
23 set(WASM_LINKER_FLAGS "${WASM_LINKER_FLAGS} -s DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1") |
1464 | 24 add_definitions( |
25 -DDISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1 | |
26 ) | |
27 | |
1549
a48ae10857b1
packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
28 |
1464 | 29 # Stone of Orthanc configuration |
30 # --------------------------------------------------------------- | |
31 set(ALLOW_DOWNLOADS ON) | |
32 | |
1542 | 33 include(${CMAKE_SOURCE_DIR}/../../../OrthancStone/Resources/CMake/OrthancStoneParameters.cmake) |
1464 | 34 |
1474
d1dde1f86d4a
fix build of wasm samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1471
diff
changeset
|
35 SET(ENABLE_DCMTK OFF) # Not necessary |
1464 | 36 SET(ENABLE_GOOGLE_TEST OFF) |
37 SET(ENABLE_LOCALE ON) # Necessary for text rendering | |
38 SET(ENABLE_WASM ON) | |
39 SET(ORTHANC_SANDBOXED ON) | |
40 | |
1471
28c64c246312
working on a shared library
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1465
diff
changeset
|
41 # 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
|
42 # populate the ORTHANC_STONE_SOURCES CMake variable |
1512
244ad1e4e76a
reorganization of folders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1506
diff
changeset
|
43 include(${ORTHANC_STONE_ROOT}/Resources/CMake/OrthancStoneConfiguration.cmake) |
1471
28c64c246312
working on a shared library
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1465
diff
changeset
|
44 |
1464 | 45 |
46 # We embed a font to be used for on-screen overlays | |
47 # --------------------------------------------------------------- | |
48 | |
49 DownloadPackage( | |
50 "a24b8136b8f3bb93f166baf97d9328de" | |
51 "http://orthanc.osimis.io/ThirdPartyDownloads/ubuntu-font-family-0.83.zip" | |
52 "${CMAKE_BINARY_DIR}/ubuntu-font-family-0.83") | |
53 | |
1471
28c64c246312
working on a shared library
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1465
diff
changeset
|
54 EmbedResources( |
1474
d1dde1f86d4a
fix build of wasm samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1471
diff
changeset
|
55 COLORMAP_HOT ${ORTHANC_STONE_ROOT}/Resources/Colormaps/hot.lut |
1464 | 56 UBUNTU_FONT ${CMAKE_BINARY_DIR}/ubuntu-font-family-0.83/Ubuntu-R.ttf |
57 ) | |
58 | |
59 add_library(OrthancStone STATIC | |
60 ${ORTHANC_STONE_SOURCES} | |
1471
28c64c246312
working on a shared library
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1465
diff
changeset
|
61 ${AUTOGENERATED_SOURCES} |
1464 | 62 ) |
63 | |
64 ################################################################################ | |
65 | |
66 # Define the WASM module | |
67 # --------------------------------------------------------------- | |
68 | |
69 project(RtViewerWasm) | |
70 | |
71 add_executable(RtViewerWasm | |
72 RtViewer/RtViewerWasm.cpp | |
73 ../Common/RtViewerApp.cpp | |
74 ../Common/RtViewerApp.h | |
75 ../Common/RtViewerView.cpp | |
76 ../Common/RtViewerView.h | |
77 ) | |
78 | |
1549
a48ae10857b1
packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
79 set_target_properties(RtViewerWasm |
a48ae10857b1
packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
80 PROPERTIES |
a48ae10857b1
packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
81 COMPILE_FLAGS "${WASM_FLAGS}" |
a48ae10857b1
packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
82 LINK_FLAGS "${WASM_LINKER_FLAGS}" |
a48ae10857b1
packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
83 ) |
a48ae10857b1
packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
84 |
1464 | 85 target_link_libraries(RtViewerWasm OrthancStone) |
86 | |
87 # Declare installation files for the module | |
88 # --------------------------------------------------------------- | |
89 install( | |
90 TARGETS RtViewerWasm | |
1548
65eccce95882
unifying the default install prefix for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1542
diff
changeset
|
91 RUNTIME DESTINATION ${ORTHANC_STONE_INSTALL_PREFIX}/RtViewer/ |
1464 | 92 ) |
93 | |
94 # Declare installation files for the companion files (web scaffolding) | |
95 # please note that ${CMAKE_CURRENT_BINARY_DIR}/RtViewerWasm.js | |
96 # (the generated JS loader for the WASM module) is handled by the `install1` | |
97 # section above: it is considered to be the binary output of | |
98 # the linker. | |
99 # --------------------------------------------------------------- | |
100 install( | |
101 FILES | |
102 ${CMAKE_SOURCE_DIR}/RtViewer/RtViewerWasmApp.js | |
103 ${CMAKE_SOURCE_DIR}/RtViewer/index.html | |
104 ${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
|
105 DESTINATION ${ORTHANC_STONE_INSTALL_PREFIX}/RtViewer/ |
1464 | 106 ) |
107 | |
108 ################################################################################ | |
109 | |
110 # Define the WASM module | |
111 # --------------------------------------------------------------- | |
112 | |
113 project(SingleFrameViewerWasm) | |
114 | |
115 add_executable(SingleFrameViewerWasm | |
116 SingleFrameViewer/SingleFrameViewer.cpp | |
117 ) | |
118 | |
1549
a48ae10857b1
packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1548
diff
changeset
|
119 set_target_properties(SingleFrameViewerWasm |
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(SingleFrameViewerWasm OrthancStone) |
126 | |
127 # Declare installation files for the module | |
128 # --------------------------------------------------------------- | |
129 install( | |
130 TARGETS SingleFrameViewerWasm | |
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}/SingleFrameViewer/ |
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}/SingleFrameViewer/SingleFrameViewerApp.js | |
143 ${CMAKE_SOURCE_DIR}/SingleFrameViewer/index.html | |
144 ${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
|
145 DESTINATION ${ORTHANC_STONE_INSTALL_PREFIX}/SingleFrameViewer/ |
1464 | 146 ) |