annotate Samples/WebAssembly/RtViewer/CMakeLists.txt @ 1426:1e132fe7090e

fix dynamic linking
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 15 May 2020 13:04:34 +0200
parents 3e644f6fadd4
children 70b0b1dc1de4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1384
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
1 cmake_minimum_required(VERSION 2.8.3)
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
2
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
3 project(RtViewerWasm)
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
4
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
5 # Configuration of the Emscripten compiler for WebAssembly target
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
6 # ---------------------------------------------------------------
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
7 set(USE_WASM ON CACHE BOOL "")
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
8 set(ORTHANC_FRAMEWORK_ROOT ${CMAKE_CURRENT_LIST_DIR}/../../../../orthanc CACHE STRING "")
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
9 set(STONE_ROOT ${CMAKE_CURRENT_LIST_DIR}/../../../)
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
10
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
11 set(EMSCRIPTEN_SET_LLVM_WASM_BACKEND ON CACHE BOOL "")
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
12
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
13 set(WASM_FLAGS "-s WASM=1 -s FETCH=1")
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
14 if (CMAKE_BUILD_TYPE STREQUAL "Debug")
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
15 set(WASM_FLAGS "${WASM_FLAGS} -s SAFE_HEAP=1")
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
16 endif()
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
17
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
18 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WASM_FLAGS}")
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
19 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WASM_FLAGS}")
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
20
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
21 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s EXTRA_EXPORTED_RUNTIME_METHODS='[\"ccall\", \"cwrap\"]'")
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
22 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s ERROR_ON_UNDEFINED_SYMBOLS=1")
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
23 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s ASSERTIONS=1 -s DISABLE_EXCEPTION_CATCHING=0")
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
24 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s ALLOW_MEMORY_GROWTH=1 -s TOTAL_MEMORY=268435456") # 256MB + resize
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
25 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1")
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
26 add_definitions(
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
27 -DDISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
28 )
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
29
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
30 # Stone of Orthanc configuration
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
31 # ---------------------------------------------------------------
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
32 set(ALLOW_DOWNLOADS ON)
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
33 set(ORTHANC_FRAMEWORK_SOURCE "path")
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
34
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
35 include(${STONE_ROOT}/Resources/CMake/OrthancStoneParameters.cmake)
1393
27e0a00bd3e8 RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
36 include(${ORTHANC_ROOT}/Resources/CMake/DownloadPackage.cmake)
1384
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
37
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
38 SET(ENABLE_DCMTK ON)
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
39 SET(ENABLE_GOOGLE_TEST OFF)
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
40 SET(ENABLE_LOCALE ON) # Necessary for text rendering
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
41 SET(ENABLE_WASM ON)
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
42 SET(ORTHANC_SANDBOXED ON)
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
43
1393
27e0a00bd3e8 RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
44
27e0a00bd3e8 RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
45 # We embed a font to be used for on-screen overlays
27e0a00bd3e8 RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
46 # ---------------------------------------------------------------
27e0a00bd3e8 RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
47
27e0a00bd3e8 RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
48 DownloadPackage(
27e0a00bd3e8 RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
49 "a24b8136b8f3bb93f166baf97d9328de"
27e0a00bd3e8 RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
50 "http://orthanc.osimis.io/ThirdPartyDownloads/ubuntu-font-family-0.83.zip"
27e0a00bd3e8 RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
51 "${CMAKE_BINARY_DIR}/ubuntu-font-family-0.83")
27e0a00bd3e8 RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
52
27e0a00bd3e8 RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
53 set(ORTHANC_STONE_APPLICATION_RESOURCES
27e0a00bd3e8 RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
54 UBUNTU_FONT ${CMAKE_BINARY_DIR}/ubuntu-font-family-0.83/Ubuntu-R.ttf
27e0a00bd3e8 RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
55 )
27e0a00bd3e8 RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
56
1384
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
57 # this will set up the build system for Stone of Orthanc and will
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
58 # populate the ORTHANC_STONE_SOURCES CMake variable
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
59 include(${STONE_ROOT}/Resources/CMake/OrthancStoneConfiguration.cmake)
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
60
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
61 include_directories(${STONE_ROOT})
1393
27e0a00bd3e8 RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
62 include_directories(../../Common)
1384
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
63
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
64 # Define the WASM module
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
65 # ---------------------------------------------------------------
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
66 add_executable(RtViewerWasm
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
67 RtViewerWasm.cpp
1404
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
68 ../../Common/RtViewerApp.cpp
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
69 ../../Common/RtViewerApp.h
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
70 ../../Common/RtViewerView.cpp
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
71 ../../Common/RtViewerView.h
1384
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
72 ${ORTHANC_STONE_SOURCES}
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
73 )
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
74
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
75 # Declare installation files for the module
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
76 # ---------------------------------------------------------------
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
77 install(
1389
5c83be3a6be5 split SDL / common + RtViewer rename + html test file
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
78 TARGETS RtViewerWasm
1384
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
79 RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
80 )
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
81
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
82 # Declare installation files for the companion files (web scaffolding)
1389
5c83be3a6be5 split SDL / common + RtViewer rename + html test file
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
83 # please note that ${CMAKE_CURRENT_BINARY_DIR}/RtViewerWasm.js
1384
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
84 # (the generated JS loader for the WASM module) is handled by the `install1`
1389
5c83be3a6be5 split SDL / common + RtViewer rename + html test file
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
85 # section above: it is considered to be the binary output of
5c83be3a6be5 split SDL / common + RtViewer rename + html test file
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
86 # the linker.
1384
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
87 # ---------------------------------------------------------------
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
88 install(
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
89 FILES
1393
27e0a00bd3e8 RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents: 1389
diff changeset
90 ${CMAKE_SOURCE_DIR}/RtViewerWasmApp.js
1384
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
91 ${CMAKE_SOURCE_DIR}/index.html
1389
5c83be3a6be5 split SDL / common + RtViewer rename + html test file
Benjamin Golinvaux <bgo@osimis.io>
parents: 1384
diff changeset
92 ${CMAKE_CURRENT_BINARY_DIR}/RtViewerWasm.wasm
1384
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
93 DESTINATION ${CMAKE_INSTALL_PREFIX}
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
94 )