Mercurial > hg > orthanc-stone
annotate Platforms/Wasm/CMakeLists.txt @ 260:c887eddd48f1 am-2
merge
author | am@osimis.io |
---|---|
date | Tue, 17 Jul 2018 14:43:42 +0200 |
parents | 9afafb192180 |
children | dc1beee33134 |
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) |
f598ffb81cda
fix sandboxed build
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
114
diff
changeset
|
34 SET(ENABLE_SDL OFF) |
f598ffb81cda
fix sandboxed build
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
114
diff
changeset
|
35 |
f598ffb81cda
fix sandboxed build
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
114
diff
changeset
|
36 include(../../Resources/CMake/OrthancStoneConfiguration.cmake) |
f598ffb81cda
fix sandboxed build
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
114
diff
changeset
|
37 |
114 | 38 add_library(OrthancStone STATIC ${ORTHANC_STONE_SOURCES}) |
39 | |
115
f598ffb81cda
fix sandboxed build
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
114
diff
changeset
|
40 |
f598ffb81cda
fix sandboxed build
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
114
diff
changeset
|
41 |
237
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
236
diff
changeset
|
42 # 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
|
43 # 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
|
44 add_custom_command( |
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
236
diff
changeset
|
45 OUTPUT "${AUTOGENERATED_DIR}/WasmWebService.c" |
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
236
diff
changeset
|
46 COMMAND ${CMAKE_COMMAND} -E touch "${AUTOGENERATED_DIR}/WasmWebService.c" "" |
257 | 47 DEPENDS "${ORTHANC_STONE_ROOT}/Platforms/Wasm/WasmWebService.js") |
115
f598ffb81cda
fix sandboxed build
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
114
diff
changeset
|
48 |
237
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
236
diff
changeset
|
49 add_custom_command( |
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
236
diff
changeset
|
50 OUTPUT "${AUTOGENERATED_DIR}/default-library.c" |
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
236
diff
changeset
|
51 COMMAND ${CMAKE_COMMAND} -E touch "${AUTOGENERATED_DIR}/default-library.c" "" |
257 | 52 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
|
53 |
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
236
diff
changeset
|
54 |
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 ## Build all the sample applications |
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 |
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
236
diff
changeset
|
59 include_directories(${ORTHANC_STONE_ROOT}) |
115
f598ffb81cda
fix sandboxed build
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
114
diff
changeset
|
60 |
f598ffb81cda
fix sandboxed build
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
114
diff
changeset
|
61 |
237
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
236
diff
changeset
|
62 macro(BuildSample Target Header Sample) |
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
236
diff
changeset
|
63 add_executable(${Target} |
255 | 64 ${STONE_WASM_SOURCES} |
237
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
236
diff
changeset
|
65 |
257 | 66 ${AUTOGENERATED_DIR}/WasmWebService.c |
67 ${AUTOGENERATED_DIR}/default-library.c | |
68 | |
237
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
236
diff
changeset
|
69 ${ORTHANC_STONE_ROOT}/Applications/Samples/SampleMainWasm.cpp |
242 | 70 # ${ORTHANC_STONE_ROOT}/Applications/Samples/SampleApplicationContext.cpp |
237
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
236
diff
changeset
|
71 ${ORTHANC_STONE_ROOT}/Applications/Samples/SampleInteractor.h |
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
236
diff
changeset
|
72 ${ORTHANC_STONE_ROOT}/Applications/Samples/SampleApplicationBase.h |
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
236
diff
changeset
|
73 ${ORTHANC_STONE_ROOT}/Applications/Samples/${Header} |
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
236
diff
changeset
|
74 ) |
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
236
diff
changeset
|
75 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
|
76 target_link_libraries(${Target} OrthancStone) |
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
236
diff
changeset
|
77 endmacro() |
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
236
diff
changeset
|
78 |
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
236
diff
changeset
|
79 #BuildSample(OrthancStoneEmpty EmptyApplication.h 1) |
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
236
diff
changeset
|
80 #BuildSample(OrthancStoneTestPattern TestPatternApplication.h 2) |
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
236
diff
changeset
|
81 #BuildSample(OrthancStoneSingleFrame SingleFrameApplication.h 3) |
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
236
diff
changeset
|
82 #BuildSample(OrthancStoneSingleVolume SingleVolumeApplication.h 4) |
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
236
diff
changeset
|
83 #BuildSample(OrthancStoneBasicPetCtFusion 5) |
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
236
diff
changeset
|
84 #BuildSample(OrthancStoneSynchronizedSeries 6) |
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
236
diff
changeset
|
85 #BuildSample(OrthancStoneLayoutPetCtFusion 7) |
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
236
diff
changeset
|
86 BuildSample(OrthancStoneSimpleViewer SimpleViewerApplication.h 8) |