# HG changeset patch # User Sebastien Jodogne # Date 1505916712 -7200 # Node ID 3541fc81331a98d1b20254302db9e51619b1fc0e # Parent 2eca030792aa0164a0c26a5227102801489ac3c7 starting WebAssembly diff -r 2eca030792aa -r 3541fc81331a CMakeLists.txt --- a/CMakeLists.txt Wed Sep 20 15:32:32 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,67 +0,0 @@ -cmake_minimum_required(VERSION 2.8) -project(OrthancStone) - - -##################################################################### -## Build a static library containing the Orthanc Stone framework -##################################################################### - -SET(STONE_SANDBOXED OFF) -include(Resources/CMake/OrthancStone.cmake) -add_library(OrthancStone STATIC ${ORTHANC_STONE_SOURCES}) - - -##################################################################### -## Build all the sample applications -##################################################################### - -macro(BuildSample Target Sample) - add_executable(${Target} - Applications/Samples/SampleMainSdl.cpp - ${APPLICATIONS_SOURCES} - ) - set_target_properties(${Target} PROPERTIES COMPILE_DEFINITIONS ORTHANC_STONE_SAMPLE=${Sample}) - target_link_libraries(${Target} OrthancStone) -endmacro() - -# TODO - Re-enable this stuff! - -#BuildSample(OrthancStoneEmpty 1) -#BuildSample(OrthancStoneTestPattern 2) -#BuildSample(OrthancStoneSingleFrame 3) -#BuildSample(OrthancStoneSingleVolume 4) -#BuildSample(OrthancStoneBasicPetCtFusion 5) -#BuildSample(OrthancStoneSynchronizedSeries 6) -#BuildSample(OrthancStoneLayoutPetCtFusion 7) - - -##################################################################### -## Build the unit tests -##################################################################### - -add_executable(UnitTests - ${GOOGLE_TEST_SOURCES} - UnitTestsSources/UnitTestsMain.cpp - ) - -target_link_libraries(UnitTests OrthancStone) - - -##################################################################### -## Generate the documentation if Doxygen is present -##################################################################### - -find_package(Doxygen) -if (DOXYGEN_FOUND) - configure_file( - ${ORTHANC_STONE_DIR}/Resources/OrthancStone.doxygen - ${CMAKE_CURRENT_BINARY_DIR}/OrthancStone.doxygen - @ONLY) - - add_custom_target(doc - ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/OrthancStone.doxygen - COMMENT "Generating documentation with Doxygen" VERBATIM - ) -else() - message("Doxygen not found. The documentation will not be built.") -endif() diff -r 2eca030792aa -r 3541fc81331a Platforms/Generic/CMakeLists.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Platforms/Generic/CMakeLists.txt Wed Sep 20 16:11:52 2017 +0200 @@ -0,0 +1,67 @@ +cmake_minimum_required(VERSION 2.8) +project(OrthancStone) + + +##################################################################### +## Build a static library containing the Orthanc Stone framework +##################################################################### + +SET(STONE_SANDBOXED OFF) +include(../../Resources/CMake/OrthancStone.cmake) +add_library(OrthancStone STATIC ${ORTHANC_STONE_SOURCES}) + + +##################################################################### +## Build all the sample applications +##################################################################### + +macro(BuildSample Target Sample) + add_executable(${Target} + ${ORTHANC_STONE_DIR}/Applications/Samples/SampleMainSdl.cpp + ${APPLICATIONS_SOURCES} + ) + set_target_properties(${Target} PROPERTIES COMPILE_DEFINITIONS ORTHANC_STONE_SAMPLE=${Sample}) + target_link_libraries(${Target} OrthancStone) +endmacro() + +# TODO - Re-enable this stuff! + +#BuildSample(OrthancStoneEmpty 1) +#BuildSample(OrthancStoneTestPattern 2) +#BuildSample(OrthancStoneSingleFrame 3) +#BuildSample(OrthancStoneSingleVolume 4) +#BuildSample(OrthancStoneBasicPetCtFusion 5) +#BuildSample(OrthancStoneSynchronizedSeries 6) +#BuildSample(OrthancStoneLayoutPetCtFusion 7) + + +##################################################################### +## Build the unit tests +##################################################################### + +add_executable(UnitTests + ${GOOGLE_TEST_SOURCES} + ${ORTHANC_STONE_DIR}/UnitTestsSources/UnitTestsMain.cpp + ) + +target_link_libraries(UnitTests OrthancStone) + + +##################################################################### +## Generate the documentation if Doxygen is present +##################################################################### + +find_package(Doxygen) +if (DOXYGEN_FOUND) + configure_file( + ${ORTHANC_STONE_DIR}/Resources/OrthancStone.doxygen + ${CMAKE_CURRENT_BINARY_DIR}/OrthancStone.doxygen + @ONLY) + + add_custom_target(doc + ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/OrthancStone.doxygen + COMMENT "Generating documentation with Doxygen" VERBATIM + ) +else() + message("Doxygen not found. The documentation will not be built.") +endif() diff -r 2eca030792aa -r 3541fc81331a Platforms/WebAssembly/CMakeLists.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Platforms/WebAssembly/CMakeLists.txt Wed Sep 20 16:11:52 2017 +0200 @@ -0,0 +1,41 @@ +# Usage: +# cmake -DCMAKE_TOOLCHAIN_FILE=~/Downloads/emsdk/emscripten/incoming/cmake/Modules/Platform/Emscripten.cmake ~/Subversion/orthanc-stone/Platforms/WebAssembly + + +cmake_minimum_required(VERSION 2.8.3) + + +##################################################################### +## Configuration of Emscripten for WebAssembly target +##################################################################### + +set(WASM_FLAGS "-s WASM=1") +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") + +# 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 ALLOW_MEMORY_GROWTH=1 -s TOTAL_MEMORY=1073741824") # 1GB + resize + +# To debug exceptions +#set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s DEMANGLE_SUPPORT=1 -s ASSERTIONS=2") + + + +##################################################################### +## Build a static library containing the Orthanc Stone framework +##################################################################### + +SET(STONE_SANDBOXED ON) +include(../../Resources/CMake/OrthancStone.cmake) +add_library(OrthancStone STATIC ${ORTHANC_STONE_SOURCES}) + +# 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") diff -r 2eca030792aa -r 3541fc81331a Platforms/WebAssembly/library.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Platforms/WebAssembly/library.js Wed Sep 20 16:11:52 2017 +0200 @@ -0,0 +1,2 @@ +mergeInto(LibraryManager.library, { +}); diff -r 2eca030792aa -r 3541fc81331a Resources/CMake/OrthancStone.cmake --- a/Resources/CMake/OrthancStone.cmake Wed Sep 20 15:32:32 2017 +0200 +++ b/Resources/CMake/OrthancStone.cmake Wed Sep 20 16:11:52 2017 +0200 @@ -54,9 +54,12 @@ ## Configure the Orthanc Framework ##################################################################### -if (NOT STONE_SANDBOXED) +if (STONE_SANDBOXED) + UNSET(ENABLE_CURL CACHE) + UNSET(ENABLE_LOGGING CACHE) + UNSET(ENABLE_SDL CACHE) +else() SET(ORTHANC_BOOST_COMPONENTS program_options) - SET(ENABLE_CURL ON) SET(ENABLE_CRYPTO_OPTIONS ON) SET(ENABLE_WEB_CLIENT ON) endif() @@ -164,6 +167,15 @@ link_libraries(mingw32) endif() +if (STONE_SANDBOXED) + # Remove functions not suitable for a sandboxed environment + list(REMOVE_ITEM ORTHANC_CORE_SOURCES + ${ZLIB_SOURCES_DIR}/gzlib.c + ${ZLIB_SOURCES_DIR}/gzwrite.c + ${ZLIB_SOURCES_DIR}/gzread.c + ) +endif() + #####################################################################