Mercurial > hg > orthanc-stone
annotate Platforms/Wasm/CMakeLists.txt @ 294:faccc4b07b92 am-2
renamings
author | am@osimis.io |
---|---|
date | Thu, 30 Aug 2018 17:17:11 +0200 |
parents | dc1beee33134 |
children |
rev | line source |
---|---|
128 | 1 # Usage (Linux): |
2 # source ~/Downloads/emsdk/emsdk_env.sh && cmake -DCMAKE_TOOLCHAIN_FILE=${EMSCRIPTEN}/cmake/Modules/Platform/Emscripten.cmake .. | |
114 | 3 |
4 cmake_minimum_required(VERSION 2.8.3) | |
5 | |
6 | |
7 ##################################################################### | |
115
f598ffb81cda
fix sandboxed build
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
114
diff
changeset
|
8 ## Configuration of the Emscripten compiler for WebAssembly target |
114 | 9 ##################################################################### |
10 | |
11 set(WASM_FLAGS "-s WASM=1") | |
237
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
236
diff
changeset
|
12 set(WASM_MODULE_NAME "StoneFrameworkModule" CACHE STRING "Name of the WebAssembly module") |
114 | 13 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WASM_FLAGS}") |
14 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WASM_FLAGS}") | |
237
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
236
diff
changeset
|
15 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --js-library ${STONE_SOURCES_DIR}/Applications/Samples/samples-library.js --js-library ${STONE_SOURCES_DIR}/Platforms/Wasm/WasmWebService.js --js-library ${STONE_SOURCES_DIR}/Platforms/Wasm/default-library.js -s EXTRA_EXPORTED_RUNTIME_METHODS='[\"ccall\", \"cwrap\"]'") |
114 | 16 |
17 # Handling of memory | |
18 #set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s ALLOW_MEMORY_GROWTH=1") # Resize | |
19 #set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s TOTAL_MEMORY=536870912") # 512MB | |
237
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
236
diff
changeset
|
20 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s EXPORT_NAME='\"${WASM_MODULE_NAME}\"' -s ALLOW_MEMORY_GROWTH=1 -s TOTAL_MEMORY=536870912 -s TOTAL_STACK=128000000") # 512MB + resize |
114 | 21 #set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s ALLOW_MEMORY_GROWTH=1 -s TOTAL_MEMORY=1073741824") # 1GB + resize |
22 | |
23 # To debug exceptions | |
24 #set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s DEMANGLE_SUPPORT=1 -s ASSERTIONS=2") | |
25 | |
26 | |
27 ##################################################################### | |
28 ## Build a static library containing the Orthanc Stone framework | |
29 ##################################################################### | |
30 | |
115
f598ffb81cda
fix sandboxed build
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
114
diff
changeset
|
31 include(../../Resources/CMake/OrthancStoneParameters.cmake) |
f598ffb81cda
fix sandboxed build
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
114
diff
changeset
|
32 |
f598ffb81cda
fix sandboxed build
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
114
diff
changeset
|
33 SET(ORTHANC_SANDBOXED ON) |
274
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
257
diff
changeset
|
34 SET(ENABLE_QT OFF) |
115
f598ffb81cda
fix sandboxed build
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
114
diff
changeset
|
35 SET(ENABLE_SDL OFF) |
274
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
257
diff
changeset
|
36 add_definitions(-DORTHANC_ENABLE_WASM=1) |
115
f598ffb81cda
fix sandboxed build
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
114
diff
changeset
|
37 |
f598ffb81cda
fix sandboxed build
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
114
diff
changeset
|
38 include(../../Resources/CMake/OrthancStoneConfiguration.cmake) |
f598ffb81cda
fix sandboxed build
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
114
diff
changeset
|
39 |
114 | 40 add_library(OrthancStone STATIC ${ORTHANC_STONE_SOURCES}) |
41 | |
115
f598ffb81cda
fix sandboxed build
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
114
diff
changeset
|
42 |
f598ffb81cda
fix sandboxed build
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
114
diff
changeset
|
43 |
237
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
236
diff
changeset
|
44 # Regenerate a dummy "WasmWebService.c" file each time the "WasmWebService.js" file |
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
236
diff
changeset
|
45 # is modified, so as to force a new execution of the linking |
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
236
diff
changeset
|
46 add_custom_command( |
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
236
diff
changeset
|
47 OUTPUT "${AUTOGENERATED_DIR}/WasmWebService.c" |
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
236
diff
changeset
|
48 COMMAND ${CMAKE_COMMAND} -E touch "${AUTOGENERATED_DIR}/WasmWebService.c" "" |
257 | 49 DEPENDS "${ORTHANC_STONE_ROOT}/Platforms/Wasm/WasmWebService.js") |
115
f598ffb81cda
fix sandboxed build
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
114
diff
changeset
|
50 |
237
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
236
diff
changeset
|
51 add_custom_command( |
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
236
diff
changeset
|
52 OUTPUT "${AUTOGENERATED_DIR}/default-library.c" |
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
236
diff
changeset
|
53 COMMAND ${CMAKE_COMMAND} -E touch "${AUTOGENERATED_DIR}/default-library.c" "" |
257 | 54 DEPENDS "${ORTHANC_STONE_ROOT}/Platforms/Wasm/default-library.js") |
237
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
236
diff
changeset
|
55 |
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
236
diff
changeset
|
56 |
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
236
diff
changeset
|
57 ##################################################################### |
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
236
diff
changeset
|
58 ## Build all the sample applications |
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
236
diff
changeset
|
59 ##################################################################### |
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
236
diff
changeset
|
60 |
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
236
diff
changeset
|
61 include_directories(${ORTHANC_STONE_ROOT}) |
115
f598ffb81cda
fix sandboxed build
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
114
diff
changeset
|
62 |
f598ffb81cda
fix sandboxed build
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
114
diff
changeset
|
63 |
237
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
236
diff
changeset
|
64 macro(BuildSample Target Header Sample) |
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
236
diff
changeset
|
65 add_executable(${Target} |
255 | 66 ${STONE_WASM_SOURCES} |
237
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
236
diff
changeset
|
67 |
257 | 68 ${AUTOGENERATED_DIR}/WasmWebService.c |
69 ${AUTOGENERATED_DIR}/default-library.c | |
70 | |
237
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
236
diff
changeset
|
71 ${ORTHANC_STONE_ROOT}/Applications/Samples/SampleMainWasm.cpp |
242 | 72 # ${ORTHANC_STONE_ROOT}/Applications/Samples/SampleApplicationContext.cpp |
237
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
236
diff
changeset
|
73 ${ORTHANC_STONE_ROOT}/Applications/Samples/SampleInteractor.h |
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
236
diff
changeset
|
74 ${ORTHANC_STONE_ROOT}/Applications/Samples/SampleApplicationBase.h |
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
236
diff
changeset
|
75 ${ORTHANC_STONE_ROOT}/Applications/Samples/${Header} |
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
236
diff
changeset
|
76 ) |
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
236
diff
changeset
|
77 set_target_properties(${Target} PROPERTIES COMPILE_DEFINITIONS ORTHANC_STONE_SAMPLE=${Sample}) |
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
236
diff
changeset
|
78 target_link_libraries(${Target} OrthancStone) |
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
236
diff
changeset
|
79 endmacro() |
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
236
diff
changeset
|
80 |
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
236
diff
changeset
|
81 #BuildSample(OrthancStoneEmpty EmptyApplication.h 1) |
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
236
diff
changeset
|
82 #BuildSample(OrthancStoneTestPattern TestPatternApplication.h 2) |
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
236
diff
changeset
|
83 #BuildSample(OrthancStoneSingleFrame SingleFrameApplication.h 3) |
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
236
diff
changeset
|
84 #BuildSample(OrthancStoneSingleVolume SingleVolumeApplication.h 4) |
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
236
diff
changeset
|
85 #BuildSample(OrthancStoneBasicPetCtFusion 5) |
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
236
diff
changeset
|
86 #BuildSample(OrthancStoneSynchronizedSeries 6) |
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
236
diff
changeset
|
87 #BuildSample(OrthancStoneLayoutPetCtFusion 7) |
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
236
diff
changeset
|
88 BuildSample(OrthancStoneSimpleViewer SimpleViewerApplication.h 8) |