Mercurial > hg > orthanc-stone
comparison Applications/StoneWebViewer/WebAssembly/CMakeLists.txt @ 1538:d1806b4e4839
moving OrthancStone/Samples/ as Applications/Samples/
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 11 Aug 2020 13:24:38 +0200 |
parents | StoneWebViewer/WebAssembly/CMakeLists.txt@433cf964838d |
children | 8ddf77198ed7 |
comparison
equal
deleted
inserted
replaced
1537:de8cf5859e84 | 1538:d1806b4e4839 |
---|---|
1 cmake_minimum_required(VERSION 2.8.3) | |
2 | |
3 project(OrthancStone) | |
4 | |
5 # Configuration of the Emscripten compiler for WebAssembly target | |
6 # --------------------------------------------------------------- | |
7 set(USE_WASM ON CACHE BOOL "") | |
8 | |
9 set(EMSCRIPTEN_SET_LLVM_WASM_BACKEND ON CACHE BOOL "") | |
10 | |
11 set(WASM_FLAGS "-s WASM=1 -s FETCH=1") | |
12 if (CMAKE_BUILD_TYPE STREQUAL "Debug") | |
13 set(WASM_FLAGS "${WASM_FLAGS} -s SAFE_HEAP=1") | |
14 endif() | |
15 | |
16 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WASM_FLAGS}") | |
17 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WASM_FLAGS}") | |
18 | |
19 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s EXTRA_EXPORTED_RUNTIME_METHODS='[\"ccall\", \"cwrap\"]'") | |
20 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s ERROR_ON_UNDEFINED_SYMBOLS=1") | |
21 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s ASSERTIONS=1 -s DISABLE_EXCEPTION_CATCHING=0") | |
22 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s ALLOW_MEMORY_GROWTH=1 -s TOTAL_MEMORY=268435456") # 256MB + resize | |
23 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1") | |
24 add_definitions( | |
25 -DDISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1 | |
26 ) | |
27 | |
28 # Stone of Orthanc configuration | |
29 # --------------------------------------------------------------- | |
30 set(ALLOW_DOWNLOADS ON) | |
31 | |
32 include(${CMAKE_SOURCE_DIR}/../../OrthancStone/Resources/CMake/OrthancStoneParameters.cmake) | |
33 | |
34 SET(ENABLE_DCMTK ON) | |
35 SET(ENABLE_DCMTK_NETWORKING OFF) | |
36 SET(ENABLE_DCMTK_TRANSCODING OFF) | |
37 SET(ENABLE_GOOGLE_TEST OFF) | |
38 SET(ENABLE_LOCALE ON) # Necessary for text rendering | |
39 SET(ENABLE_WASM ON) | |
40 SET(ORTHANC_SANDBOXED ON) | |
41 | |
42 # this will set up the build system for Stone of Orthanc and will | |
43 # populate the ORTHANC_STONE_SOURCES CMake variable | |
44 include(${ORTHANC_STONE_ROOT}/Resources/CMake/OrthancStoneConfiguration.cmake) | |
45 | |
46 if (CMAKE_BUILD_TYPE MATCHES Debug) | |
47 # specific flags go here | |
48 elseif (CMAKE_BUILD_TYPE MATCHES RelWithDebInfo) | |
49 # specific flags go here | |
50 elseif (CMAKE_BUILD_TYPE MATCHES Release) | |
51 # specific flags go here | |
52 else() | |
53 message(FATAL_ERROR "CMAKE_BUILD_TYPE must match either Debug, RelWithDebInfo or Release" ) | |
54 endif() | |
55 | |
56 ################################################################################ | |
57 | |
58 project(StoneWebViewer) | |
59 | |
60 | |
61 # Create the wrapper to call C++ from JavaScript | |
62 # --------------------------------------------------------------- | |
63 | |
64 set(LIBCLANG "libclang-4.0.so.1" CACHE PATH "Version of clang to generate the code model") | |
65 set(STONE_WRAPPER ${CMAKE_CURRENT_BINARY_DIR}/stone.js) | |
66 | |
67 add_custom_command( | |
68 COMMAND | |
69 ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/ParseWebAssemblyExports.py --libclang=${LIBCLANG} ${CMAKE_SOURCE_DIR}/StoneWebViewer.cpp > ${STONE_WRAPPER} | |
70 DEPENDS | |
71 ${CMAKE_SOURCE_DIR}/StoneWebViewer.cpp | |
72 ${CMAKE_SOURCE_DIR}/ParseWebAssemblyExports.py | |
73 OUTPUT | |
74 ${STONE_WRAPPER} | |
75 ) | |
76 | |
77 add_custom_target(StoneWrapper | |
78 DEPENDS | |
79 ${STONE_WRAPPER} | |
80 ) | |
81 | |
82 | |
83 # Define the WASM module | |
84 # --------------------------------------------------------------- | |
85 | |
86 add_executable(StoneWebViewer | |
87 ${ORTHANC_STONE_SOURCES} | |
88 ${AUTOGENERATED_SOURCES} | |
89 StoneWebViewer.cpp | |
90 ) | |
91 | |
92 # Make sure to have the wrapper generated | |
93 add_dependencies(StoneWebViewer StoneWrapper) | |
94 | |
95 | |
96 # Declare installation files for the module | |
97 # --------------------------------------------------------------- | |
98 | |
99 install( | |
100 TARGETS StoneWebViewer | |
101 RUNTIME DESTINATION . | |
102 ) | |
103 | |
104 | |
105 # Declare installation files for the companion files (web scaffolding) | |
106 # please note that ${CMAKE_CURRENT_BINARY_DIR}/StoneWebViewer.js | |
107 # (the generated JS loader for the WASM module) is handled by the `install` | |
108 # section above: it is considered to be the binary output of | |
109 # the linker. | |
110 # --------------------------------------------------------------- | |
111 install( | |
112 FILES | |
113 ${CMAKE_CURRENT_BINARY_DIR}/StoneWebViewer.wasm | |
114 ${CMAKE_SOURCE_DIR}/../WebApplication/app.css | |
115 ${CMAKE_SOURCE_DIR}/../WebApplication/app.js | |
116 ${CMAKE_SOURCE_DIR}/../WebApplication/index.html | |
117 ${STONE_WRAPPER} | |
118 DESTINATION . | |
119 ) | |
120 | |
121 install( | |
122 FILES | |
123 ${CMAKE_SOURCE_DIR}/../WebApplication/img/grid1x1.png | |
124 ${CMAKE_SOURCE_DIR}/../WebApplication/img/grid1x2.png | |
125 ${CMAKE_SOURCE_DIR}/../WebApplication/img/grid2x1.png | |
126 ${CMAKE_SOURCE_DIR}/../WebApplication/img/grid2x2.png | |
127 ${CMAKE_SOURCE_DIR}/../WebApplication/img/loading.gif | |
128 DESTINATION img | |
129 ) |