annotate 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
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)
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
36
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
37 SET(ENABLE_DCMTK ON)
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
38 SET(ENABLE_GOOGLE_TEST OFF)
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
39 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
40 SET(ENABLE_WASM ON)
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
41 SET(ORTHANC_SANDBOXED ON)
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
42
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
43 # 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
44 # populate the ORTHANC_STONE_SOURCES CMake variable
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
45 include(${STONE_ROOT}/Resources/CMake/OrthancStoneConfiguration.cmake)
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
46
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
47 include_directories(${STONE_ROOT})
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
48
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
49 # Define the WASM module
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
50 # ---------------------------------------------------------------
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
51 add_executable(RtViewerWasm
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
52 RtViewerWasm.cpp
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
53 ../../Common/RtViewer.cpp
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
54 ../../Common/RtViewer.h
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
55
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
56 ${ORTHANC_STONE_SOURCES}
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
57 )
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
58
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
59 # Declare installation files for the module
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 install(
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
62 TARGETS CtDoseStructViewerWasm
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
63 RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
64 )
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 # Declare installation files for the companion files (web scaffolding)
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
67 # please note that ${CMAKE_CURRENT_BINARY_DIR}/SingleFrameViewerWasm.js
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
68 # (the generated JS loader for the WASM module) is handled by the `install1`
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
69 # section above
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
70 # ---------------------------------------------------------------
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
71 install(
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
72 FILES
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
73 ${CMAKE_SOURCE_DIR}/CtDoseStructViewerApp.js
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
74 ${CMAKE_SOURCE_DIR}/index.html
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
75 ${CMAKE_CURRENT_BINARY_DIR}/CtDoseStructViewerWasm.wasm
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
76 ${CMAKE_SOURCE_DIR}/WasmWrapper.js
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
77 DESTINATION ${CMAKE_INSTALL_PREFIX}
24bcff8ea58f RtViewer : SDL ok. Preparation for WASM builds ongoing
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
78 )