comparison Applications/Samples/WebAssembly/RtViewer/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 OrthancStone/Samples/WebAssembly/RtViewer/CMakeLists.txt@244ad1e4e76a
children
comparison
equal deleted inserted replaced
1537:de8cf5859e84 1538:d1806b4e4839
1 cmake_minimum_required(VERSION 2.8.3)
2
3 project(RtViewerWasm)
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}/../../../Resources/CMake/OrthancStoneParameters.cmake)
33
34 SET(ENABLE_DCMTK OFF) # Not necessary
35 SET(ENABLE_GOOGLE_TEST OFF)
36 SET(ENABLE_LOCALE ON) # Necessary for text rendering
37 SET(ENABLE_WASM ON)
38 SET(ORTHANC_SANDBOXED ON)
39
40 # this will set up the build system for Stone of Orthanc and will
41 # populate the ORTHANC_STONE_SOURCES CMake variable
42 include(${ORTHANC_STONE_ROOT}/Resources/CMake/OrthancStoneConfiguration.cmake)
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 EmbedResources(
54 COLORMAP_HOT ${ORTHANC_STONE_ROOT}/Resources/Colormaps/hot.lut
55 UBUNTU_FONT ${CMAKE_BINARY_DIR}/ubuntu-font-family-0.83/Ubuntu-R.ttf
56 )
57
58 # Define the WASM module
59 # ---------------------------------------------------------------
60 add_executable(RtViewerWasm
61 RtViewerWasm.cpp
62 ../../Common/RtViewerApp.cpp
63 ../../Common/RtViewerApp.h
64 ../../Common/RtViewerView.cpp
65 ../../Common/RtViewerView.h
66 ${ORTHANC_STONE_SOURCES}
67 ${AUTOGENERATED_SOURCES}
68 )
69
70 # Declare installation files for the module
71 # ---------------------------------------------------------------
72 install(
73 TARGETS RtViewerWasm
74 RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}
75 )
76
77 # Declare installation files for the companion files (web scaffolding)
78 # please note that ${CMAKE_CURRENT_BINARY_DIR}/RtViewerWasm.js
79 # (the generated JS loader for the WASM module) is handled by the `install1`
80 # section above: it is considered to be the binary output of
81 # the linker.
82 # ---------------------------------------------------------------
83 install(
84 FILES
85 ${CMAKE_SOURCE_DIR}/RtViewerWasmApp.js
86 ${CMAKE_SOURCE_DIR}/index.html
87 ${CMAKE_CURRENT_BINARY_DIR}/RtViewerWasm.wasm
88 DESTINATION ${CMAKE_INSTALL_PREFIX}
89 )