Mercurial > hg > orthanc-stone
diff 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 |
line wrap: on
line diff
--- a/Platforms/Wasm/CMakeLists.txt Tue Jun 19 16:06:32 2018 +0200 +++ b/Platforms/Wasm/CMakeLists.txt Wed Jun 20 09:03:48 2018 +0200 @@ -9,14 +9,15 @@ ##################################################################### set(WASM_FLAGS "-s WASM=1") +set(WASM_MODULE_NAME "StoneFrameworkModule" CACHE STRING "Name of the WebAssembly module") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WASM_FLAGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WASM_FLAGS}") -set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --js-library ${CMAKE_SOURCE_DIR}/library.js") +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\"]'") # Handling of memory #set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s ALLOW_MEMORY_GROWTH=1") # Resize #set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s TOTAL_MEMORY=536870912") # 512MB -set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s ALLOW_MEMORY_GROWTH=1 -s TOTAL_MEMORY=536870912") # 512MB + resize +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 #set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s ALLOW_MEMORY_GROWTH=1 -s TOTAL_MEMORY=1073741824") # 1GB + resize # To debug exceptions @@ -38,12 +39,46 @@ +# Regenerate a dummy "WasmWebService.c" file each time the "WasmWebService.js" file +# is modified, so as to force a new execution of the linking +add_custom_command( + OUTPUT "${AUTOGENERATED_DIR}/WasmWebService.c" + COMMAND ${CMAKE_COMMAND} -E touch "${AUTOGENERATED_DIR}/WasmWebService.c" "" + DEPENDS "${ORTHANC_STONE_ROOT}/Platforms/WebAssembly/WasmWebService.js") +add_custom_command( + OUTPUT "${AUTOGENERATED_DIR}/default-library.c" + COMMAND ${CMAKE_COMMAND} -E touch "${AUTOGENERATED_DIR}/default-library.c" "" + DEPENDS "${ORTHANC_STONE_ROOT}/Platforms/WebAssembly/default-library.js") + + +##################################################################### +## Build all the sample applications +##################################################################### + +include_directories(${ORTHANC_STONE_ROOT}) -# Regenerate a dummy "library.c" file each time the "library.js" file -# is modified, so as to force a new execution of the linking -add_custom_command( - OUTPUT "${AUTOGENERATED_DIR}/library.c" - COMMAND ${CMAKE_COMMAND} -E touch "${AUTOGENERATED_DIR}/library.c" "" - DEPENDS "${CMAKE_SOURCE_DIR}/library.js") +macro(BuildSample Target Header Sample) + add_executable(${Target} + ${ORTHANC_STONE_ROOT}/Platforms/Wasm/Defaults.cpp + ${ORTHANC_STONE_ROOT}/Platforms/Wasm/WasmWebService.cpp + + ${ORTHANC_STONE_ROOT}/Applications/Samples/SampleMainWasm.cpp + ${ORTHANC_STONE_ROOT}/Applications/Samples/SampleApplicationContext.cpp + ${ORTHANC_STONE_ROOT}/Applications/Samples/SampleInteractor.h + ${ORTHANC_STONE_ROOT}/Applications/Samples/SampleApplicationBase.h + ${ORTHANC_STONE_ROOT}/Applications/Samples/${Header} + ) + set_target_properties(${Target} PROPERTIES COMPILE_DEFINITIONS ORTHANC_STONE_SAMPLE=${Sample}) + target_link_libraries(${Target} OrthancStone) +endmacro() + +#BuildSample(OrthancStoneEmpty EmptyApplication.h 1) +#BuildSample(OrthancStoneTestPattern TestPatternApplication.h 2) +#BuildSample(OrthancStoneSingleFrame SingleFrameApplication.h 3) +#BuildSample(OrthancStoneSingleVolume SingleVolumeApplication.h 4) +#BuildSample(OrthancStoneBasicPetCtFusion 5) +#BuildSample(OrthancStoneSynchronizedSeries 6) +#BuildSample(OrthancStoneLayoutPetCtFusion 7) +BuildSample(OrthancStoneSimpleViewer SimpleViewerApplication.h 8)