comparison Samples/WebAssembly/CMakeLists.txt @ 1419:f5493e5a51a3

single CMakeLists.txt for all SDL samples & unit tests + another one for all Wasm samples
author Alain Mazy <alain@mazy.be>
date Wed, 13 May 2020 12:42:52 +0200
parents
children 9e7015edd107
comparison
equal deleted inserted replaced
1415:998697c5ec74 1419:f5493e5a51a3
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 STRING "")
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/DownloadPackage.cmake)
37
38 SET(ENABLE_DCMTK ON)
39 SET(ENABLE_GOOGLE_TEST OFF)
40 SET(ENABLE_LOCALE ON) # Necessary for text rendering
41 SET(ENABLE_WASM ON)
42 SET(ORTHANC_SANDBOXED ON)
43
44
45 # We embed a font to be used for on-screen overlays
46 # ---------------------------------------------------------------
47
48 DownloadPackage(
49 "a24b8136b8f3bb93f166baf97d9328de"
50 "http://orthanc.osimis.io/ThirdPartyDownloads/ubuntu-font-family-0.83.zip"
51 "${CMAKE_BINARY_DIR}/ubuntu-font-family-0.83")
52
53 set(ORTHANC_STONE_APPLICATION_RESOURCES
54 UBUNTU_FONT ${CMAKE_BINARY_DIR}/ubuntu-font-family-0.83/Ubuntu-R.ttf
55 )
56
57 # this will set up the build system for Stone of Orthanc and will
58 # populate the ORTHANC_STONE_SOURCES CMake variable
59 include(${STONE_ROOT}/Resources/CMake/OrthancStoneConfiguration.cmake)
60
61 include_directories(${STONE_ROOT})
62 include_directories(../Common)
63
64 add_library(OrthancStone STATIC
65 ${ORTHANC_STONE_SOURCES}
66 )
67
68 ################################################################################
69
70 # Define the WASM module
71 # ---------------------------------------------------------------
72
73 project(RtViewerWasm)
74
75 add_executable(RtViewerWasm
76 RtViewer/RtViewerWasm.cpp
77 ../Common/RtViewer.cpp
78 ../Common/RtViewer.h
79 )
80
81 target_link_libraries(RtViewerWasm OrthancStone)
82
83 # Declare installation files for the module
84 # ---------------------------------------------------------------
85 install(
86 TARGETS RtViewerWasm
87 RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/RtViewer/
88 )
89
90 # Declare installation files for the companion files (web scaffolding)
91 # please note that ${CMAKE_CURRENT_BINARY_DIR}/RtViewerWasm.js
92 # (the generated JS loader for the WASM module) is handled by the `install1`
93 # section above: it is considered to be the binary output of
94 # the linker.
95 # ---------------------------------------------------------------
96 install(
97 FILES
98 ${CMAKE_SOURCE_DIR}/RtViewer/RtViewerWasmApp.js
99 ${CMAKE_SOURCE_DIR}/RtViewer/index.html
100 ${CMAKE_CURRENT_BINARY_DIR}/RtViewerWasm.wasm
101 DESTINATION ${CMAKE_INSTALL_PREFIX}/RtViewer/
102 )
103
104 ################################################################################
105
106 # Define the WASM module
107 # ---------------------------------------------------------------
108
109 project(SingleFrameViewerWasm)
110
111 add_executable(SingleFrameViewerWasm
112 SingleFrameViewer/SingleFrameViewer.cpp
113 )
114
115 target_link_libraries(SingleFrameViewerWasm OrthancStone)
116
117 # Declare installation files for the module
118 # ---------------------------------------------------------------
119 install(
120 TARGETS SingleFrameViewerWasm
121 RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/SingleFrameViewer/
122 )
123
124 # Declare installation files for the companion files (web scaffolding)
125 # please note that ${CMAKE_CURRENT_BINARY_DIR}/RtViewerWasm.js
126 # (the generated JS loader for the WASM module) is handled by the `install1`
127 # section above: it is considered to be the binary output of
128 # the linker.
129 # ---------------------------------------------------------------
130 install(
131 FILES
132 ${CMAKE_SOURCE_DIR}/SingleFrameViewer/SingleFrameViewerApp.js
133 ${CMAKE_SOURCE_DIR}/SingleFrameViewer/index.html
134 ${CMAKE_CURRENT_BINARY_DIR}/SingleFrameViewerWasm.wasm
135 DESTINATION ${CMAKE_INSTALL_PREFIX}/SingleFrameViewer/
136 )