annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1354
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
1 cmake_minimum_required(VERSION 2.8.3)
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
2
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
3 # Configuration of the Emscripten compiler for WebAssembly target
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
4 # ---------------------------------------------------------------
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
5 set(USE_WASM ON CACHE BOOL "")
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
6 set(ORTHANC_FRAMEWORK_ROOT ${CMAKE_CURRENT_LIST_DIR}/../../../../orthanc CACHE STRING "")
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
7 set(STONE_ROOT ${CMAKE_CURRENT_LIST_DIR}/../../../../orthanc-stone)
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
8
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
9 set(EMSCRIPTEN_SET_LLVM_WASM_BACKEND ON CACHE BOOL "")
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
10
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
11 set(WASM_FLAGS "-s WASM=1 -s FETCH=1")
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
12 if (CMAKE_BUILD_TYPE STREQUAL "Debug")
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
13 set(WASM_FLAGS "${WASM_FLAGS} -s SAFE_HEAP=1")
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
14 endif()
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
15
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
16 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WASM_FLAGS}")
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
17 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WASM_FLAGS}")
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
18
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
19 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s EXTRA_EXPORTED_RUNTIME_METHODS='[\"ccall\", \"cwrap\"]'")
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
20 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s ERROR_ON_UNDEFINED_SYMBOLS=1")
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
21 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s ASSERTIONS=1 -s DISABLE_EXCEPTION_CATCHING=0")
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
22 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s ALLOW_MEMORY_GROWTH=1 -s TOTAL_MEMORY=268435456") # 256MB + resize
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
23 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1")
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
24
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
25 # Stone of Orthanc configuration
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
26 # ---------------------------------------------------------------
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
27 set(ALLOW_DOWNLOADS ON)
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
28 set(ORTHANC_FRAMEWORK_SOURCE "path")
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
29
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
30 include(${STONE_ROOT}/Resources/CMake/OrthancStoneParameters.cmake)
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
31
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
32 SET(ENABLE_DCMTK ON)
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
33 SET(ENABLE_GOOGLE_TEST OFF)
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
34 SET(ENABLE_LOCALE ON) # Necessary for text rendering
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
35 SET(ENABLE_WASM ON)
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
36 SET(ORTHANC_SANDBOXED ON)
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
37
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
38 # this will set up the build system for Stone of Orthanc and will
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
39 # populate the ORTHANC_STONE_SOURCES CMake variable
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
40 include(${STONE_ROOT}/Resources/CMake/OrthancStoneConfiguration.cmake)
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
41
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
42 include_directories(${STONE_ROOT})
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
43
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
44 # Define the WASM module
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
45 # ---------------------------------------------------------------
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
46 add_executable(SingleFrameViewerWasm
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
47 test.cpp
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
48 ${ORTHANC_STONE_SOURCES}
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
49 )
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
50
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
51 # Declare installation files for the module
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
52 # ---------------------------------------------------------------
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
53 install(
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
54 TARGETS SingleFrameViewerWasm
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
55 RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
56 )
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
57
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
58 # Declare installation files for the companion files (web scaffolding)
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
59 # please note that ${CMAKE_CURRENT_BINARY_DIR}/SingleFrameViewerWasm.js
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
60 # (the generated JS loader for the WASM module) is handled by the `install1`
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
61 # section above
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
62 # ---------------------------------------------------------------
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
63 install(
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
64 FILES
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
65 ${CMAKE_SOURCE_DIR}/SingleFrameViewerApp.js
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
66 ${CMAKE_SOURCE_DIR}/index.html
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
67 ${CMAKE_CURRENT_BINARY_DIR}/SingleFrameViewerWasm.wasm
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
68 ${CMAKE_SOURCE_DIR}/WasmWrapper.js
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
69 DESTINATION ${CMAKE_INSTALL_PREFIX}
c0e4eb14c912 SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
70 )