comparison Samples/WebAssembly/SingleFrameViewer/CMakeLists.txt @ 1354:c0e4eb14c912 broker

SingleFrameViewer WASM working OK
author Benjamin Golinvaux <bgo@osimis.io>
date Wed, 15 Apr 2020 12:59:15 +0200
parents
children 4971b1c5dfa6
comparison
equal deleted inserted replaced
1353:af65bce18951 1354:c0e4eb14c912
1 cmake_minimum_required(VERSION 2.8.3)
2
3 # Configuration of the Emscripten compiler for WebAssembly target
4 # ---------------------------------------------------------------
5 set(USE_WASM ON CACHE BOOL "")
6 set(ORTHANC_FRAMEWORK_ROOT ${CMAKE_CURRENT_LIST_DIR}/../../../../orthanc CACHE STRING "")
7 set(STONE_ROOT ${CMAKE_CURRENT_LIST_DIR}/../../../../orthanc-stone)
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
25 # Stone of Orthanc configuration
26 # ---------------------------------------------------------------
27 set(ALLOW_DOWNLOADS ON)
28 set(ORTHANC_FRAMEWORK_SOURCE "path")
29
30 include(${STONE_ROOT}/Resources/CMake/OrthancStoneParameters.cmake)
31
32 SET(ENABLE_DCMTK ON)
33 SET(ENABLE_GOOGLE_TEST OFF)
34 SET(ENABLE_LOCALE ON) # Necessary for text rendering
35 SET(ENABLE_WASM ON)
36 SET(ORTHANC_SANDBOXED ON)
37
38 # this will set up the build system for Stone of Orthanc and will
39 # populate the ORTHANC_STONE_SOURCES CMake variable
40 include(${STONE_ROOT}/Resources/CMake/OrthancStoneConfiguration.cmake)
41
42 include_directories(${STONE_ROOT})
43
44 # Define the WASM module
45 # ---------------------------------------------------------------
46 add_executable(SingleFrameViewerWasm
47 test.cpp
48 ${ORTHANC_STONE_SOURCES}
49 )
50
51 # Declare installation files for the module
52 # ---------------------------------------------------------------
53 install(
54 TARGETS SingleFrameViewerWasm
55 RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}
56 )
57
58 # Declare installation files for the companion files (web scaffolding)
59 # please note that ${CMAKE_CURRENT_BINARY_DIR}/SingleFrameViewerWasm.js
60 # (the generated JS loader for the WASM module) is handled by the `install1`
61 # section above
62 # ---------------------------------------------------------------
63 install(
64 FILES
65 ${CMAKE_SOURCE_DIR}/SingleFrameViewerApp.js
66 ${CMAKE_SOURCE_DIR}/index.html
67 ${CMAKE_CURRENT_BINARY_DIR}/SingleFrameViewerWasm.wasm
68 ${CMAKE_SOURCE_DIR}/WasmWrapper.js
69 DESTINATION ${CMAKE_INSTALL_PREFIX}
70 )