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