Mercurial > hg > orthanc-stone
comparison Platforms/Wasm/CMakeLists.txt @ 237:b4642964c355 am
SimpleViewer demo running both with SDL and Wasm
author | am@osimis.io |
---|---|
date | Wed, 20 Jun 2018 09:03:48 +0200 |
parents | f73d722d98c8 |
children | 092db46c6291 |
comparison
equal
deleted
inserted
replaced
236:f73d722d98c8 | 237:b4642964c355 |
---|---|
7 ##################################################################### | 7 ##################################################################### |
8 ## Configuration of the Emscripten compiler for WebAssembly target | 8 ## Configuration of the Emscripten compiler for WebAssembly target |
9 ##################################################################### | 9 ##################################################################### |
10 | 10 |
11 set(WASM_FLAGS "-s WASM=1") | 11 set(WASM_FLAGS "-s WASM=1") |
12 set(WASM_MODULE_NAME "StoneFrameworkModule" CACHE STRING "Name of the WebAssembly module") | |
12 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WASM_FLAGS}") | 13 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WASM_FLAGS}") |
13 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WASM_FLAGS}") | 14 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WASM_FLAGS}") |
14 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --js-library ${CMAKE_SOURCE_DIR}/library.js") | 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\"]'") |
15 | 16 |
16 # Handling of memory | 17 # Handling of memory |
17 #set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s ALLOW_MEMORY_GROWTH=1") # Resize | 18 #set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s ALLOW_MEMORY_GROWTH=1") # Resize |
18 #set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s TOTAL_MEMORY=536870912") # 512MB | 19 #set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s TOTAL_MEMORY=536870912") # 512MB |
19 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s ALLOW_MEMORY_GROWTH=1 -s TOTAL_MEMORY=536870912") # 512MB + resize | 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 |
20 #set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s ALLOW_MEMORY_GROWTH=1 -s TOTAL_MEMORY=1073741824") # 1GB + resize | 21 #set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s ALLOW_MEMORY_GROWTH=1 -s TOTAL_MEMORY=1073741824") # 1GB + resize |
21 | 22 |
22 # To debug exceptions | 23 # To debug exceptions |
23 #set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s DEMANGLE_SUPPORT=1 -s ASSERTIONS=2") | 24 #set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s DEMANGLE_SUPPORT=1 -s ASSERTIONS=2") |
24 | 25 |
36 | 37 |
37 add_library(OrthancStone STATIC ${ORTHANC_STONE_SOURCES}) | 38 add_library(OrthancStone STATIC ${ORTHANC_STONE_SOURCES}) |
38 | 39 |
39 | 40 |
40 | 41 |
42 # Regenerate a dummy "WasmWebService.c" file each time the "WasmWebService.js" file | |
43 # is modified, so as to force a new execution of the linking | |
44 add_custom_command( | |
45 OUTPUT "${AUTOGENERATED_DIR}/WasmWebService.c" | |
46 COMMAND ${CMAKE_COMMAND} -E touch "${AUTOGENERATED_DIR}/WasmWebService.c" "" | |
47 DEPENDS "${ORTHANC_STONE_ROOT}/Platforms/WebAssembly/WasmWebService.js") | |
48 | |
49 add_custom_command( | |
50 OUTPUT "${AUTOGENERATED_DIR}/default-library.c" | |
51 COMMAND ${CMAKE_COMMAND} -E touch "${AUTOGENERATED_DIR}/default-library.c" "" | |
52 DEPENDS "${ORTHANC_STONE_ROOT}/Platforms/WebAssembly/default-library.js") | |
41 | 53 |
42 | 54 |
55 ##################################################################### | |
56 ## Build all the sample applications | |
57 ##################################################################### | |
43 | 58 |
44 # Regenerate a dummy "library.c" file each time the "library.js" file | 59 include_directories(${ORTHANC_STONE_ROOT}) |
45 # is modified, so as to force a new execution of the linking | 60 |
46 add_custom_command( | 61 |
47 OUTPUT "${AUTOGENERATED_DIR}/library.c" | 62 macro(BuildSample Target Header Sample) |
48 COMMAND ${CMAKE_COMMAND} -E touch "${AUTOGENERATED_DIR}/library.c" "" | 63 add_executable(${Target} |
49 DEPENDS "${CMAKE_SOURCE_DIR}/library.js") | 64 ${ORTHANC_STONE_ROOT}/Platforms/Wasm/Defaults.cpp |
65 ${ORTHANC_STONE_ROOT}/Platforms/Wasm/WasmWebService.cpp | |
66 | |
67 ${ORTHANC_STONE_ROOT}/Applications/Samples/SampleMainWasm.cpp | |
68 ${ORTHANC_STONE_ROOT}/Applications/Samples/SampleApplicationContext.cpp | |
69 ${ORTHANC_STONE_ROOT}/Applications/Samples/SampleInteractor.h | |
70 ${ORTHANC_STONE_ROOT}/Applications/Samples/SampleApplicationBase.h | |
71 ${ORTHANC_STONE_ROOT}/Applications/Samples/${Header} | |
72 ) | |
73 set_target_properties(${Target} PROPERTIES COMPILE_DEFINITIONS ORTHANC_STONE_SAMPLE=${Sample}) | |
74 target_link_libraries(${Target} OrthancStone) | |
75 endmacro() | |
76 | |
77 #BuildSample(OrthancStoneEmpty EmptyApplication.h 1) | |
78 #BuildSample(OrthancStoneTestPattern TestPatternApplication.h 2) | |
79 #BuildSample(OrthancStoneSingleFrame SingleFrameApplication.h 3) | |
80 #BuildSample(OrthancStoneSingleVolume SingleVolumeApplication.h 4) | |
81 #BuildSample(OrthancStoneBasicPetCtFusion 5) | |
82 #BuildSample(OrthancStoneSynchronizedSeries 6) | |
83 #BuildSample(OrthancStoneLayoutPetCtFusion 7) | |
84 BuildSample(OrthancStoneSimpleViewer SimpleViewerApplication.h 8) |