comparison Samples/WebAssembly/RtViewer/CMakeLists.txt @ 1384:24bcff8ea58f

RtViewer : SDL ok. Preparation for WASM builds ongoing
author Benjamin Golinvaux <bgo@osimis.io>
date Mon, 27 Apr 2020 10:01:48 +0200
parents
children 5c83be3a6be5
comparison
equal deleted inserted replaced
1383:ab871499ed30 1384:24bcff8ea58f
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 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
37 SET(ENABLE_DCMTK ON)
38 SET(ENABLE_GOOGLE_TEST OFF)
39 SET(ENABLE_LOCALE ON) # Necessary for text rendering
40 SET(ENABLE_WASM ON)
41 SET(ORTHANC_SANDBOXED ON)
42
43 # this will set up the build system for Stone of Orthanc and will
44 # populate the ORTHANC_STONE_SOURCES CMake variable
45 include(${STONE_ROOT}/Resources/CMake/OrthancStoneConfiguration.cmake)
46
47 include_directories(${STONE_ROOT})
48
49 # Define the WASM module
50 # ---------------------------------------------------------------
51 add_executable(RtViewerWasm
52 RtViewerWasm.cpp
53 ../../Common/RtViewer.cpp
54 ../../Common/RtViewer.h
55
56 ${ORTHANC_STONE_SOURCES}
57 )
58
59 # Declare installation files for the module
60 # ---------------------------------------------------------------
61 install(
62 TARGETS CtDoseStructViewerWasm
63 RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}
64 )
65
66 # Declare installation files for the companion files (web scaffolding)
67 # please note that ${CMAKE_CURRENT_BINARY_DIR}/SingleFrameViewerWasm.js
68 # (the generated JS loader for the WASM module) is handled by the `install1`
69 # section above
70 # ---------------------------------------------------------------
71 install(
72 FILES
73 ${CMAKE_SOURCE_DIR}/CtDoseStructViewerApp.js
74 ${CMAKE_SOURCE_DIR}/index.html
75 ${CMAKE_CURRENT_BINARY_DIR}/CtDoseStructViewerWasm.wasm
76 ${CMAKE_SOURCE_DIR}/WasmWrapper.js
77 DESTINATION ${CMAKE_INSTALL_PREFIX}
78 )