Mercurial > hg > orthanc-stone
changeset 1901:184b0aeae1af
fix build of sdl
line wrap: on
line diff
--- a/Applications/Samples/Sdl/CMakeLists.txt Sat Jan 29 12:51:51 2022 +0100 +++ b/Applications/Samples/Sdl/CMakeLists.txt Sat Jan 29 16:55:14 2022 +0100 @@ -25,7 +25,7 @@ set(ORTHANC_FRAMEWORK_DEFAULT_SOURCE "hg") set(ORTHANC_FRAMEWORK_DEFAULT_VERSION "mainline") -include(${CMAKE_SOURCE_DIR}/../../Platforms/Sdl/OrthancStoneSdlParameters.cmake) +include(${CMAKE_SOURCE_DIR}/../../../OrthancStone/Resources/CMake/OrthancStoneSdlParameters.cmake) if (ORTHANC_FRAMEWORK_SOURCE STREQUAL "system") set(ORTHANC_BOOST_COMPONENTS program_options) @@ -47,7 +47,7 @@ set(ENABLE_SDL ON) SET(ENABLE_PUGIXML ON) # To test compilation of OsiriX annotations -include(${CMAKE_SOURCE_DIR}/../../Platforms/Sdl/OrthancStoneSdlConfiguration.cmake) +include(${CMAKE_SOURCE_DIR}/../../../OrthancStone/Resources/CMake/OrthancStoneSdlConfiguration.cmake) include(${CMAKE_SOURCE_DIR}/Utilities.cmake) include(${CMAKE_SOURCE_DIR}/../../../OrthancStone/UnitTestsSources/UnitTestsSources.cmake)
--- a/Applications/Samples/Sdl/RtViewer/RtViewerSdl.cpp Sat Jan 29 12:51:51 2022 +0100 +++ b/Applications/Samples/Sdl/RtViewer/RtViewerSdl.cpp Sat Jan 29 16:55:14 2022 +0100 @@ -28,9 +28,9 @@ // Stone of Orthanc includes #include "../../../../OrthancStone/Sources/Loaders/GenericLoadersContext.h" #include "../../../../OrthancStone/Sources/OpenGL/OpenGLIncludes.h" +#include "../../../../OrthancStone/Sources/Platforms/Sdl/SdlOpenGLContext.h" #include "../../../../OrthancStone/Sources/StoneException.h" #include "../../../../OrthancStone/Sources/StoneInitialization.h" -#include "../../../Platforms/Sdl/SdlOpenGLContext.h" // Orthanc (a.o. for screenshot capture) #include <Compatibility.h> // For std::unique_ptr<>
--- a/Applications/Samples/Sdl/SdlHelpers.h Sat Jan 29 12:51:51 2022 +0100 +++ b/Applications/Samples/Sdl/SdlHelpers.h Sat Jan 29 16:55:14 2022 +0100 @@ -26,7 +26,7 @@ # error This file cannot be used if ORTHANC_ENABLE_SDL != 1 #endif -#include "../../Platforms/Sdl/SdlViewport.h" +#include "../../../OrthancStone/Sources/Platforms/Sdl/SdlViewport.h" #include <boost/shared_ptr.hpp>
--- a/Applications/Samples/Sdl/SingleFrameViewer/SdlSimpleViewer.cpp Sat Jan 29 12:51:51 2022 +0100 +++ b/Applications/Samples/Sdl/SingleFrameViewer/SdlSimpleViewer.cpp Sat Jan 29 16:55:14 2022 +0100 @@ -30,6 +30,7 @@ #include "../../Common/SampleHelpers.h" #include "../../../../OrthancStone/Sources/Loaders/GenericLoadersContext.h" +#include "../../../../OrthancStone/Sources/Platforms/Sdl/SdlViewport.h" #include "../../../../OrthancStone/Sources/Scene2D/AnnotationsSceneLayer.h" #include "../../../../OrthancStone/Sources/Scene2DViewport/AngleMeasureTool.h" #include "../../../../OrthancStone/Sources/Scene2DViewport/LineMeasureTool.h" @@ -37,7 +38,6 @@ #include "../../../../OrthancStone/Sources/StoneException.h" #include "../../../../OrthancStone/Sources/StoneInitialization.h" #include "../../../../OrthancStone/Sources/Viewport/DefaultViewportInteractor.h" -#include "../../../Platforms/Sdl/SdlViewport.h" #include <EmbeddedResources.h> #include <Compatibility.h> // For std::unique_ptr<>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/OrthancStone/Resources/CMake/OrthancStoneSdlConfiguration.cmake Sat Jan 29 16:55:14 2022 +0100 @@ -0,0 +1,74 @@ +# Stone of Orthanc +# Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics +# Department, University Hospital of Liege, Belgium +# Copyright (C) 2017-2022 Osimis S.A., Belgium +# Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation, either version 3 of +# the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this program. If not, see +# <http://www.gnu.org/licenses/>. + +##################################################################### +## Sanity check of the configuration +##################################################################### + +include(${CMAKE_CURRENT_LIST_DIR}/OrthancStoneConfiguration.cmake) + +if (ORTHANC_SANDBOXED) + message(FATAL_ERROR "Cannot enable SDL in sandboxed environments") +endif() + +if (CMAKE_SYSTEM_NAME STREQUAL "Emscripten" OR + CMAKE_SYSTEM_NAME STREQUAL "PNaCl" OR + CMAKE_SYSTEM_NAME STREQUAL "NaCl32" OR + CMAKE_SYSTEM_NAME STREQUAL "NaCl64") + message(FATAL_ERROR "Trying to use a Web compiler for a native build") +endif() + + + +##################################################################### +## Configure SDL +##################################################################### + +message("SDL is enabled") +include(${CMAKE_CURRENT_LIST_DIR}/SdlConfiguration.cmake) + +add_definitions( + -DORTHANC_ENABLE_SDL=1 + -DORTHANC_ENABLE_WASM=0 + ) + +if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows" AND + NOT MSVC) + # This is necessary when compiling EXE for Windows using MinGW + link_libraries(mingw32) +endif() + + + +##################################################################### +## Additional source files for SDL +##################################################################### + +list(APPEND ORTHANC_STONE_SOURCES + ${CMAKE_CURRENT_LIST_DIR}/../../Sources/Platforms/Sdl/SdlViewport.cpp + ${CMAKE_CURRENT_LIST_DIR}/../../Sources/Platforms/Sdl/SdlWindow.cpp + ${SDL_SOURCES} + ) + +if (ENABLE_OPENGL) + list(APPEND ORTHANC_STONE_SOURCES + ${CMAKE_CURRENT_LIST_DIR}/../../Sources/Platforms/Sdl/SdlOpenGLContext.cpp + ) +endif()
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/OrthancStone/Resources/CMake/OrthancStoneSdlParameters.cmake Sat Jan 29 16:55:14 2022 +0100 @@ -0,0 +1,44 @@ +# Stone of Orthanc +# Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics +# Department, University Hospital of Liege, Belgium +# Copyright (C) 2017-2022 Osimis S.A., Belgium +# Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation, either version 3 of +# the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this program. If not, see +# <http://www.gnu.org/licenses/>. + + + + +##################################################################### +## Load generic parameters +##################################################################### + +include(${CMAKE_CURRENT_LIST_DIR}/OrthancStoneParameters.cmake) + + +##################################################################### +## CMake parameters tunable by the user +##################################################################### + +# Advanced parameters to fine-tune linking against system libraries +set(USE_SYSTEM_SDL ON CACHE BOOL "Use the system version of SDL2") + + +##################################################################### +## Internal CMake parameters to enable the optional subcomponents of +## the Stone of Orthanc +##################################################################### + +set(ENABLE_THREADS ON CACHE INTERNAL "")
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/OrthancStone/Resources/CMake/OrthancStoneWebAssemblyConfiguration.cmake Sat Jan 29 16:55:14 2022 +0100 @@ -0,0 +1,62 @@ +# Stone of Orthanc +# Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics +# Department, University Hospital of Liege, Belgium +# Copyright (C) 2017-2022 Osimis S.A., Belgium +# Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation, either version 3 of +# the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this program. If not, see +# <http://www.gnu.org/licenses/>. + + + + +##################################################################### +## Sanity check of the configuration +##################################################################### + +set(ENABLE_WEB_CLIENT OFF) +include(${CMAKE_CURRENT_LIST_DIR}/OrthancStoneConfiguration.cmake) + +if (NOT ORTHANC_SANDBOXED) + message(FATAL_ERROR "WebAssembly target must me configured as sandboxed") +endif() + +if (NOT CMAKE_SYSTEM_NAME STREQUAL "Emscripten") + message(FATAL_ERROR "WebAssembly target requires the emscripten compiler") +endif() + +add_definitions( + -DORTHANC_ENABLE_SDL=0 + -DORTHANC_ENABLE_WASM=1 + ) + + +##################################################################### +## Additional source files for WebAssembly +##################################################################### + +list(APPEND ORTHANC_STONE_SOURCES + ${CMAKE_CURRENT_LIST_DIR}/../../Sources/Platforms/WebAssembly/WebAssemblyCairoViewport.cpp + ${CMAKE_CURRENT_LIST_DIR}/../../Sources/Platforms/WebAssembly/WebAssemblyLoadersContext.cpp + ${CMAKE_CURRENT_LIST_DIR}/../../Sources/Platforms/WebAssembly/WebAssemblyOracle.cpp + ${CMAKE_CURRENT_LIST_DIR}/../../Sources/Platforms/WebAssembly/WebAssemblyViewport.cpp + ) + +if (ENABLE_OPENGL) + list(APPEND ORTHANC_STONE_SOURCES + ${CMAKE_CURRENT_LIST_DIR}/../../Sources/Platforms/WebAssembly/WebAssemblyOpenGLContext.cpp + ${CMAKE_CURRENT_LIST_DIR}/../../Sources/Platforms/WebAssembly/WebGLViewport.cpp + ${CMAKE_CURRENT_LIST_DIR}/../../Sources/Platforms/WebAssembly/WebGLViewportsRegistry.cpp + ) +endif()
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/OrthancStone/Resources/CMake/OrthancStoneWebAssemblyParameters.cmake Sat Jan 29 16:55:14 2022 +0100 @@ -0,0 +1,43 @@ +# Stone of Orthanc +# Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics +# Department, University Hospital of Liege, Belgium +# Copyright (C) 2017-2022 Osimis S.A., Belgium +# Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation, either version 3 of +# the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this program. If not, see +# <http://www.gnu.org/licenses/>. + + + + +##################################################################### +## Load generic parameters +##################################################################### + +include(${CMAKE_CURRENT_LIST_DIR}/OrthancStoneParameters.cmake) + + +##################################################################### +## CMake parameters tunable by the user +##################################################################### + +# None for now, but might contain stuff like memory settings + + +##################################################################### +## Internal CMake parameters to enable the optional subcomponents of +## the Stone of Orthanc +##################################################################### + +set(ENABLE_THREADS OFF CACHE INTERNAL "")
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/OrthancStone/Resources/CMake/SdlConfiguration.cmake Sat Jan 29 16:55:14 2022 +0100 @@ -0,0 +1,226 @@ +# Stone of Orthanc +# Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics +# Department, University Hospital of Liege, Belgium +# Copyright (C) 2017-2022 Osimis S.A., Belgium +# Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation, either version 3 of +# the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this program. If not, see +# <http://www.gnu.org/licenses/>. + + +if (STATIC_BUILD OR NOT USE_SYSTEM_SDL) + SET(SDL_SOURCES_DIR ${CMAKE_BINARY_DIR}/SDL2-2.0.4) + SET(SDL_URL "http://orthanc.osimis.io/ThirdPartyDownloads/SDL2-2.0.4.tar.gz") + SET(SDL_MD5 "44fc4a023349933e7f5d7a582f7b886e") + DownloadPackage(${SDL_MD5} ${SDL_URL} "${SDL_SOURCES_DIR}") + + include_directories(${SDL_SOURCES_DIR}/include) + + set(TMP "${SDL_SOURCES_DIR}/include/SDL_config_premake.h") + if (NOT EXISTS "${TMP}") + file(WRITE "${TMP}" " +#include \"SDL_platform.h\" +#define HAVE_STDARG_H 1 +#define HAVE_STDDEF_H 1 +#define HAVE_STDINT_H 1 +") + endif() + + # General source files + file(GLOB SDL_SOURCES + ${SDL_SOURCES_DIR}/src/*.c + ${SDL_SOURCES_DIR}/src/atomic/*.c + ${SDL_SOURCES_DIR}/src/audio/*.c + ${SDL_SOURCES_DIR}/src/cpuinfo/*.c + ${SDL_SOURCES_DIR}/src/dynapi/*.c + ${SDL_SOURCES_DIR}/src/events/*.c + ${SDL_SOURCES_DIR}/src/file/*.c + ${SDL_SOURCES_DIR}/src/haptic/*.c + ${SDL_SOURCES_DIR}/src/joystick/*.c + ${SDL_SOURCES_DIR}/src/libm/*.c + ${SDL_SOURCES_DIR}/src/power/*.c + ${SDL_SOURCES_DIR}/src/render/*.c + ${SDL_SOURCES_DIR}/src/stdlib/*.c + ${SDL_SOURCES_DIR}/src/thread/*.c + ${SDL_SOURCES_DIR}/src/timer/*.c + ${SDL_SOURCES_DIR}/src/video/*.c + + ${SDL_SOURCES_DIR}/src/loadso/dummy/*.c + #${SDL_SOURCES_DIR}/src/timer/dummy/*.c + ${SDL_SOURCES_DIR}/src/audio/dummy/*.c + ${SDL_SOURCES_DIR}/src/filesystem/dummy/*.c + ${SDL_SOURCES_DIR}/src/haptic/dummy/*.c + ${SDL_SOURCES_DIR}/src/joystick/dummy/*.c + #${SDL_SOURCES_DIR}/src/main/dummy/*.c + ${SDL_SOURCES_DIR}/src/video/dummy/*.c + ) + + add_definitions( + -DUSING_PREMAKE_CONFIG_H=1 + + -DSDL_AUDIO_DISABLED=1 + -DSDL_AUDIO_DRIVER_DUMMY=1 + -DSDL_FILESYSTEM_DISABLED=1 + -DSDL_FILESYSTEM_DUMMY=1 + -DSDL_FILE_DISABLED=1 + -DSDL_HAPTIC_DISABLED=1 + -DSDL_JOYSTICK_DISABLED=1 + + #-DSDL_THREADS_DISABLED=1 + ) + + if (CMAKE_SYSTEM_NAME STREQUAL "Linux") + file(GLOB TMP + ${SDL_SOURCES_DIR}/src/core/linux/*.c + ${SDL_SOURCES_DIR}/src/loadso/dlopen/*.c + ${SDL_SOURCES_DIR}/src/render/software/*.c + ${SDL_SOURCES_DIR}/src/thread/pthread/*.c + ${SDL_SOURCES_DIR}/src/timer/unix/*.c + ${SDL_SOURCES_DIR}/src/video/x11/*.c + ) + + list(APPEND SDL_SOURCES ${TMP}) + + add_definitions( + -DSDL_LOADSO_DLOPEN=1 + -DSDL_THREAD_PTHREAD=1 + -DSDL_TIMER_UNIX=1 + -DSDL_POWER_DISABLED=1 + + -DSDL_VIDEO_DRIVER_X11=1 + + -DSDL_ASSEMBLY_ROUTINES=1 + -DSDL_THREAD_PTHREAD_RECURSIVE_MUTEX=1 + -DSDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS=1 + -DHAVE_GCC_SYNC_LOCK_TEST_AND_SET=1 + ) + + link_libraries(X11 Xext) + + if (NOT CMAKE_SYSTEM_VERSION STREQUAL "Raspberry") + # Raspberry Pi has no support for OpenGL + file(GLOB TMP + ${SDL_SOURCES_DIR}/src/render/opengl/*.c + ${SDL_SOURCES_DIR}/src/render/opengles2/*.c + ) + + list(APPEND SDL_SOURCES ${TMP}) + + add_definitions( + -DSDL_VIDEO_OPENGL=1 + -DSDL_VIDEO_OPENGL_ES2=1 + -DSDL_VIDEO_RENDER_OGL=1 + -DSDL_VIDEO_RENDER_OGL_ES2=1 + -DSDL_VIDEO_OPENGL_GLX=1 + -DSDL_VIDEO_OPENGL_EGL=1 + ) + endif() + + elseif (CMAKE_SYSTEM_NAME STREQUAL "Windows") + file(GLOB TMP + ${SDL_SOURCES_DIR}/src/audio/directsound/*.c + ${SDL_SOURCES_DIR}/src/audio/disk/*.c + ${SDL_SOURCES_DIR}/src/audio/winmm/*.c + ${SDL_SOURCES_DIR}/src/joystick/windows/*.c + ${SDL_SOURCES_DIR}/src/haptic/windows/*.c + ${SDL_SOURCES_DIR}/src/power/windows/*.c + + ${SDL_SOURCES_DIR}/src/main/windows/*.c + ${SDL_SOURCES_DIR}/src/core/windows/*.c + ${SDL_SOURCES_DIR}/src/loadso/windows/*.c + ${SDL_SOURCES_DIR}/src/render/direct3d/*.c + ${SDL_SOURCES_DIR}/src/render/direct3d11/*.c + ${SDL_SOURCES_DIR}/src/render/opengl/*.c + ${SDL_SOURCES_DIR}/src/render/psp/*.c + ${SDL_SOURCES_DIR}/src/render/opengles/*.c + ${SDL_SOURCES_DIR}/src/render/opengles2/*.c + ${SDL_SOURCES_DIR}/src/render/software/*.c + ${SDL_SOURCES_DIR}/src/thread/generic/SDL_syscond.c # Don't include more files from "thread/generic/*.c"! + ${SDL_SOURCES_DIR}/src/thread/windows/*.c + ${SDL_SOURCES_DIR}/src/timer/windows/*.c + ${SDL_SOURCES_DIR}/src/video/windows/*.c + ${SDL_SOURCES_DIR}/src/windows/dlopen/*.c + ) + + list(APPEND SDL_SOURCES ${TMP}) + + # NB: OpenGL ES headers are not available in MinGW-W64 + add_definitions( + -DSDL_LOADSO_WINDOWS=1 + -DSDL_THREAD_WINDOWS=1 + -DSDL_TIMER_WINDOWS=1 + -DSDL_POWER_WINDOWS=1 + + -DSDL_VIDEO_OPENGL=1 + -DSDL_VIDEO_OPENGL_WGL=1 + -DSDL_VIDEO_RENDER_D3D=1 + -DSDL_VIDEO_RENDER_OGL=1 + -DSDL_VIDEO_DRIVER_WINDOWS=1 + ) + + if (MSVC) + add_definitions( + -D__FLTUSED__ + -DHAVE_LIBC=1 + ) + else() + add_definitions( + -DHAVE_GCC_ATOMICS=1 + -DSDL_ASSEMBLY_ROUTINES=1 + ) + endif() + + link_libraries(imm32 winmm version) + + elseif (CMAKE_SYSTEM_NAME STREQUAL "Darwin") + file(GLOB TMP + ${SDL_SOURCES_DIR}/src/loadso/dlopen/*.c + ${SDL_SOURCES_DIR}/src/render/opengl/*.c + ${SDL_SOURCES_DIR}/src/render/opengles2/*.c + ${SDL_SOURCES_DIR}/src/render/software/*.c + ${SDL_SOURCES_DIR}/src/thread/pthread/*.c + ${SDL_SOURCES_DIR}/src/timer/unix/*.c + ${SDL_SOURCES_DIR}/src/video/cocoa/*.m + ) + + list(APPEND SDL_SOURCES ${TMP}) + + add_definitions( + -DSDL_LOADSO_DLOPEN=1 + -DSDL_THREAD_PTHREAD=1 + -DSDL_TIMER_UNIX=1 + -DSDL_POWER_DISABLED=1 + + -DSDL_VIDEO_DRIVER_COCOA=1 + -DSDL_VIDEO_OPENGL=1 + -DSDL_VIDEO_OPENGL_CGL=1 + -DSDL_VIDEO_RENDER_OGL=1 + + -DSDL_ASSEMBLY_ROUTINES=1 + -DSDL_THREAD_PTHREAD_RECURSIVE_MUTEX=1 + ) + + find_library(CARBON_LIBRARY Carbon) + find_library(COCOA_LIBRARY Cocoa) + find_library(IOKIT_LIBRARY IOKit) + find_library(QUARTZ_LIBRARY QuartzCore) + link_libraries(${CARBON_LIBRARY} ${COCOA_LIBRARY} ${IOKIT_LIBRARY} ${QUARTZ_LIBRARY}) + + endif() + +else() + pkg_search_module(SDL2 REQUIRED sdl2) + include_directories(${SDL2_INCLUDE_DIRS}) + link_libraries(${SDL2_LIBRARIES}) +endif()
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/OrthancStone/Resources/WebAssemblySharedLibrary/CMakeLists.txt Sat Jan 29 16:55:14 2022 +0100 @@ -0,0 +1,213 @@ +# Stone of Orthanc +# Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics +# Department, University Hospital of Liege, Belgium +# Copyright (C) 2017-2022 Osimis S.A., Belgium +# Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation, either version 3 of +# the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this program. If not, see +# <http://www.gnu.org/licenses/>. + + + +cmake_minimum_required(VERSION 2.8.3) +cmake_policy(SET CMP0058 NEW) + +project(OrthancStoneModule) + + +# Warning message related to WebAssembly modules: We know that 1.38.41 +# DOES NOT work, but that 1.39.17 works. +message("") +message("=== IMPORTANT: Make sure to use a recent version of Emscripten (preferably >= 2.0.0) ===") +message("") + + +set(ORTHANC_STONE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}/../../../../wasm-binaries/OrthancStoneModule" CACHE PATH "Where to put the WebAssembly binaries") + + +# Ask for the generation of a side module +set(WASM_FLAGS "-s SIDE_MODULE=1 -s EXPORT_ALL=1") # Must be before "Compiler.cmake" + + +# Configuration of the Emscripten compiler for WebAssembly target +# --------------------------------------------------------------- + +set(USE_WASM ON CACHE BOOL "") + +set(WASM_FLAGS "${WASM_FLAGS} -s WASM=1 -s FETCH=1") +if (CMAKE_BUILD_TYPE STREQUAL "Debug") + set(WASM_FLAGS "${WASM_FLAGS} -s SAFE_HEAP=1") +endif() + +set(WASM_LINKER_FLAGS "${WASM_LINKER_FLAGS} -s ASSERTIONS=1 -s DISABLE_EXCEPTION_CATCHING=0") +set(WASM_LINKER_FLAGS "${WASM_LINKER_FLAGS} -s DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1") +add_definitions( + -DDISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1 +) + + +# Stone of Orthanc configuration +# --------------------------------------------------------------- + +include(${CMAKE_SOURCE_DIR}/../OrthancStoneWebAssemblyParameters.cmake) + +SET(ENABLE_DCMTK ON) +SET(ENABLE_DCMTK_NETWORKING OFF) +SET(ENABLE_DCMTK_TRANSCODING OFF) +SET(ENABLE_GOOGLE_TEST OFF) +SET(ENABLE_LOCALE ON) # Necessary for text rendering +SET(ORTHANC_SANDBOXED ON) + +include(${CMAKE_SOURCE_DIR}/../OrthancStoneWebAssemblyConfiguration.cmake) + + + + +################################################################################ + +# The source files that register a callback cannot be part of a side +# module, and must be compiled in the main module. The following +# command can be used to identify such files: +# $ grep -lrE 'emscripten_' ../../Sources/ + +set(SOURCES_WITH_EMSCRIPTEN_CALLBACKS + ${CMAKE_SOURCE_DIR}/../WebAssemblyOracle.cpp + ${CMAKE_SOURCE_DIR}/../WebAssemblyViewport.cpp + ${CMAKE_SOURCE_DIR}/../WebAssemblyCairoViewport.cpp + ) + +list(REMOVE_ITEM ORTHANC_STONE_SOURCES + ${SOURCES_WITH_EMSCRIPTEN_CALLBACKS} + ) + +configure_file( + ${ORTHANC_STONE_ROOT}/../SharedLibrary/OrthancStone.h.in + ${CMAKE_CURRENT_BINARY_DIR}/Include/orthanc-stone/OrthancStone.h + ) + +configure_file( + ${ORTHANC_FRAMEWORK_ROOT}/../SharedLibrary/OrthancFramework.h.in + ${CMAKE_CURRENT_BINARY_DIR}/Include/orthanc-framework/OrthancFramework.h + ) + +file( + COPY ${CMAKE_SOURCE_DIR}/../../../../OrthancStone/Sources/ + DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/Include/orthanc-stone + NO_SOURCE_PERMISSIONS + FILES_MATCHING + PATTERN "*.h" + PATTERN OrthancStone.h EXCLUDE + PATTERN "Deprecated*" EXCLUDE + ) + +file( + COPY ${ORTHANC_FRAMEWORK_ROOT}/ + DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/Include/orthanc-framework + NO_SOURCE_PERMISSIONS + FILES_MATCHING + PATTERN "*.h" + PATTERN OrthancFramework.h EXCLUDE + ) + +add_executable(OrthancStoneModule + ${ORTHANC_STONE_SOURCES} + ${AUTOGENERATED_SOURCES} + ${CAIRO_SOURCES} + ${PIXMAN_SOURCES} + ${FREETYPE_SOURCES} + ) + +set_target_properties(OrthancStoneModule + PROPERTIES + COMPILE_FLAGS "${WASM_FLAGS}" + LINK_FLAGS "${WASM_LINKER_FLAGS}" + ) + +# CMake does not natively handle SIDE_MODULE, and believes that +# Emscripten produces a ".js" file (whereas it creates only the +# ".wasm"). Create a dummy ".js" for target to work. +add_custom_command( + TARGET OrthancStoneModule POST_BUILD + COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/OrthancStoneModule.js + ) + +file( + COPY ${BOOST_SOURCES_DIR}/boost/ + DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/Include/boost/ + NO_SOURCE_PERMISSIONS + FILES_MATCHING + PATTERN "*.h" + PATTERN "*.hpp" + PATTERN "*.ipp" + ) + +file( + COPY ${JSONCPP_SOURCES_DIR}/include/json/ + DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/Include/json/ + NO_SOURCE_PERMISSIONS + FILES_MATCHING + PATTERN "*.h" + ) + +file( + COPY ${CAIRO_SOURCES_DIR}/src/ + DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/Include/cairo/ + NO_SOURCE_PERMISSIONS + FILES_MATCHING + PATTERN "*.h" + ) + +set(DCMTK_MODULES + dcmdata + config + ofstd + oflog + ) + +foreach (module IN LISTS DCMTK_MODULES) + file( + COPY ${DCMTK_SOURCES_DIR}/ofstd/include/dcmtk/${module}/ + DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/Include/dcmtk/${module}/ + NO_SOURCE_PERMISSIONS + FILES_MATCHING + PATTERN "*.h" + ) +endforeach() + + +install( + TARGETS OrthancStoneModule + DESTINATION ${ORTHANC_STONE_INSTALL_PREFIX}/lib + ) + +install(FILES + ${CMAKE_CURRENT_BINARY_DIR}/OrthancStoneModule.wasm + DESTINATION ${ORTHANC_STONE_INSTALL_PREFIX}/lib + ) + +install( + DIRECTORY + ${CMAKE_CURRENT_BINARY_DIR}/Include/boost + ${CMAKE_CURRENT_BINARY_DIR}/Include/cairo + ${CMAKE_CURRENT_BINARY_DIR}/Include/dcmtk + ${CMAKE_CURRENT_BINARY_DIR}/Include/json + ${CMAKE_CURRENT_BINARY_DIR}/Include/orthanc-framework + ${CMAKE_CURRENT_BINARY_DIR}/Include/orthanc-stone + DESTINATION ${ORTHANC_STONE_INSTALL_PREFIX}/include/ + ) + +install(FILES + ${SOURCES_WITH_EMSCRIPTEN_CALLBACKS} + DESTINATION ${ORTHANC_STONE_INSTALL_PREFIX}/src/orthanc-stone + )
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/OrthancStone/Resources/WebAssemblySharedLibrary/NOTES.txt Sat Jan 29 16:55:14 2022 +0100 @@ -0,0 +1,18 @@ + +Install Emscripten: +https://emscripten.org/docs/getting_started/downloads.html + +# cd ~/Downloads +# git clone https://github.com/emscripten-core/emsdk.git +# cd emsdk +# ./emsdk install 2.0.0 +# ./emsdk activate 2.0.0 + + +Then, if the installation path was "~/Downloads/emsdk/": + +# source ~/Downloads/emsdk/emsdk_env.sh +# cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=${EMSDK}/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake -DALLOW_DOWNLOADS=ON -G Ninja +# ninja install + +=> The binaries will be put in "../../../wasm-binaries/"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/OrthancStone/Resources/WebAssemblyUnitTests/CMakeLists.txt Sat Jan 29 16:55:14 2022 +0100 @@ -0,0 +1,139 @@ +# Stone of Orthanc +# Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics +# Department, University Hospital of Liege, Belgium +# Copyright (C) 2017-2022 Osimis S.A., Belgium +# Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation, either version 3 of +# the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this program. If not, see +# <http://www.gnu.org/licenses/>. + + + +cmake_minimum_required(VERSION 2.8.3) +cmake_policy(SET CMP0058 NEW) + +project(OrthancStone) + +set(ORTHANC_FRAMEWORK_DEFAULT_VERSION "mainline") +set(ORTHANC_FRAMEWORK_DEFAULT_SOURCE "hg") +set(ORTHANC_STONE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}/../../../wasm-binaries/" CACHE PATH "Where to put the WebAssembly binaries") + + +# Configuration of the Emscripten compiler for WebAssembly target +# --------------------------------------------------------------- +set(USE_WASM ON CACHE BOOL "") + +set(WASM_FLAGS "-s WASM=1 -s FETCH=1 -s ASSERTIONS=1 -s DISABLE_EXCEPTION_CATCHING=0") +if (CMAKE_BUILD_TYPE STREQUAL "Debug") + set(WASM_FLAGS "${WASM_FLAGS} -s SAFE_HEAP=1") +endif() + +set(WASM_LINKER_FLAGS "${WASM_LINKER_FLAGS} -s EXTRA_EXPORTED_RUNTIME_METHODS='[\"ccall\", \"cwrap\"]'") +set(WASM_LINKER_FLAGS "${WASM_LINKER_FLAGS} -s ERROR_ON_UNDEFINED_SYMBOLS=1") +set(WASM_LINKER_FLAGS "${WASM_LINKER_FLAGS} -s ALLOW_MEMORY_GROWTH=1 -s TOTAL_MEMORY=268435456") # 256MB + resize +set(WASM_LINKER_FLAGS "${WASM_LINKER_FLAGS} -s DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1") +add_definitions( + -DDISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1 +) + + +# Stone of Orthanc configuration +# --------------------------------------------------------------- +set(ALLOW_DOWNLOADS ON) + +include(${CMAKE_SOURCE_DIR}/../CMake/OrthancStoneWebAssemblyParameters.cmake) + +SET(ENABLE_DCMTK ON) # Necessary for the tests of the Orthanc framework +SET(ENABLE_PUGIXML ON) # Necessary for the tests of the Orthanc framework +SET(ENABLE_GOOGLE_TEST OFF) +SET(ENABLE_LOCALE ON) # Necessary for text rendering +SET(ENABLE_LUA ON) # Necessary for the tests of the Orthanc framework +SET(ORTHANC_SANDBOXED ON) + +# this will set up the build system for Stone of Orthanc and will +# populate the ORTHANC_STONE_SOURCES CMake variable +include(${CMAKE_SOURCE_DIR}/../CMake/OrthancStoneWebAssemblyConfiguration.cmake) + + +################################################################################ + +# Define the WASM module +# --------------------------------------------------------------- + +set(USE_SYSTEM_GOOGLE_TEST OFF CACHE BOOL "Use the system version of Google Test") +set(USE_GOOGLE_TEST_DEBIAN_PACKAGE OFF CACHE BOOL "Use the sources of Google Test shipped with libgtest-dev (Debian only)") +mark_as_advanced(USE_GOOGLE_TEST_DEBIAN_PACKAGE) +include(${ORTHANC_STONE_ROOT}/../Resources/Orthanc/CMake/DownloadPackage.cmake) +include(${ORTHANC_STONE_ROOT}/../Resources/Orthanc/CMake/GoogleTestConfiguration.cmake) + + +include(${CMAKE_SOURCE_DIR}/../../UnitTestsSources/UnitTestsSources.cmake) + +EmbedResources( + RT_STRUCT_00 ${CMAKE_SOURCE_DIR}/../../UnitTestsSources/TestStructureSet.json + ) + +add_executable(UnitTests + # Testing Stone + ${UNIT_TESTS_SOURCES} + + # Testing the Orthanc Framework + ${ORTHANC_FRAMEWORK_ROOT}/../UnitTestsSources/DicomMapTests.cpp + ${ORTHANC_FRAMEWORK_ROOT}/../UnitTestsSources/FrameworkTests.cpp + ${ORTHANC_FRAMEWORK_ROOT}/../UnitTestsSources/FromDcmtkTests.cpp + ${ORTHANC_FRAMEWORK_ROOT}/../UnitTestsSources/ImageProcessingTests.cpp + ${ORTHANC_FRAMEWORK_ROOT}/../UnitTestsSources/ImageTests.cpp + ${ORTHANC_FRAMEWORK_ROOT}/../UnitTestsSources/JpegLosslessTests.cpp + ${ORTHANC_FRAMEWORK_ROOT}/../UnitTestsSources/LoggingTests.cpp + ${ORTHANC_FRAMEWORK_ROOT}/../UnitTestsSources/LuaTests.cpp + ${ORTHANC_FRAMEWORK_ROOT}/../UnitTestsSources/RestApiTests.cpp + ${ORTHANC_FRAMEWORK_ROOT}/../UnitTestsSources/StreamTests.cpp + ${ORTHANC_FRAMEWORK_ROOT}/../UnitTestsSources/ToolboxTests.cpp + + # Tests that are not compatible with WebAssembly + + # ${ORTHANC_FRAMEWORK_ROOT}/../UnitTestsSources/FileStorageTests.cpp + # ${ORTHANC_FRAMEWORK_ROOT}/../UnitTestsSources/JobsTests.cpp + # ${ORTHANC_FRAMEWORK_ROOT}/../UnitTestsSources/MemoryCacheTests.cpp + # ${ORTHANC_FRAMEWORK_ROOT}/../UnitTestsSources/SQLiteChromiumTests.cpp + # ${ORTHANC_FRAMEWORK_ROOT}/../UnitTestsSources/SQLiteTests.cpp + # ${ORTHANC_FRAMEWORK_ROOT}/../UnitTestsSources/ZipTests.cpp + + # Shared files + ${AUTOGENERATED_SOURCES} + ${BOOST_EXTENDED_SOURCES} + ${GOOGLE_TEST_SOURCES} + ${ORTHANC_STONE_SOURCES} + ) + + +# Declare installation files for the module +# --------------------------------------------------------------- +install( + TARGETS UnitTests + RUNTIME DESTINATION ${ORTHANC_STONE_INSTALL_PREFIX}/UnitTests/ + ) + +# Declare installation files for the companion files (web scaffolding) +# please note that ${CMAKE_CURRENT_BINARY_DIR}/RtViewerWasm.js +# (the generated JS loader for the WASM module) is handled by the `install1` +# section above: it is considered to be the binary output of +# the linker. +# --------------------------------------------------------------- +install( + FILES + ${CMAKE_SOURCE_DIR}/index.html + ${CMAKE_CURRENT_BINARY_DIR}/UnitTests.wasm + DESTINATION ${ORTHANC_STONE_INSTALL_PREFIX}/UnitTests + )
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/OrthancStone/Resources/WebAssemblyUnitTests/NOTES.txt Sat Jan 29 16:55:14 2022 +0100 @@ -0,0 +1,18 @@ +Native compilation (without Docker) +=================================== + +Install Emscripten: +https://emscripten.org/docs/getting_started/downloads.html + +Then, if the installation path is "~/Downloads/emsdk/": + +# source ~/Downloads/emsdk/emsdk_env.sh +# mkdir Build && cd Build +# cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=${EMSDK}/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake -DALLOW_DOWNLOADS=ON -G Ninja +# ninja install + +=> The binaries will be put in "../../../wasm-binaries/UnitTests/" + +# cd `pwd`/../../../wasm-binaries/UnitTests +# python3 -m http.server 8000 +# firefox http://localhost:8000/index.html
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/OrthancStone/Resources/WebAssemblyUnitTests/index.html Sat Jan 29 16:55:14 2022 +0100 @@ -0,0 +1,14 @@ +<!DOCTYPE html> +<html lang="en"> + <head> + <meta charset="utf-8"> + <title>Stone of Orthanc</title> + </head> + <body> + <h1>Stone of Orthanc - Unit tests</h1> + <pre id="output"> + Running the tests... + </pre> + <script src="UnitTests.js" async></script> + </body> +</html>
--- a/OrthancStone/Sources/Platforms/Sdl/OrthancStoneSdlConfiguration.cmake Sat Jan 29 12:51:51 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,74 +0,0 @@ -# Stone of Orthanc -# Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics -# Department, University Hospital of Liege, Belgium -# Copyright (C) 2017-2022 Osimis S.A., Belgium -# Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium -# -# This program is free software: you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public License -# as published by the Free Software Foundation, either version 3 of -# the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this program. If not, see -# <http://www.gnu.org/licenses/>. - -##################################################################### -## Sanity check of the configuration -##################################################################### - -include(${ORTHANC_STONE_ROOT}/../Resources/CMake/OrthancStoneConfiguration.cmake) - -if (ORTHANC_SANDBOXED) - message(FATAL_ERROR "Cannot enable SDL in sandboxed environments") -endif() - -if (CMAKE_SYSTEM_NAME STREQUAL "Emscripten" OR - CMAKE_SYSTEM_NAME STREQUAL "PNaCl" OR - CMAKE_SYSTEM_NAME STREQUAL "NaCl32" OR - CMAKE_SYSTEM_NAME STREQUAL "NaCl64") - message(FATAL_ERROR "Trying to use a Web compiler for a native build") -endif() - - - -##################################################################### -## Configure SDL -##################################################################### - -message("SDL is enabled") -include(${CMAKE_CURRENT_LIST_DIR}/SdlConfiguration.cmake) - -add_definitions( - -DORTHANC_ENABLE_SDL=1 - -DORTHANC_ENABLE_WASM=0 - ) - -if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows" AND - NOT MSVC) - # This is necessary when compiling EXE for Windows using MinGW - link_libraries(mingw32) -endif() - - - -##################################################################### -## Additional source files for SDL -##################################################################### - -list(APPEND ORTHANC_STONE_SOURCES - ${CMAKE_CURRENT_LIST_DIR}/SdlViewport.cpp - ${CMAKE_CURRENT_LIST_DIR}/SdlWindow.cpp - ${SDL_SOURCES} - ) - -if (ENABLE_OPENGL) - list(APPEND ORTHANC_STONE_SOURCES - ${CMAKE_CURRENT_LIST_DIR}/SdlOpenGLContext.cpp - ) -endif()
--- a/OrthancStone/Sources/Platforms/Sdl/OrthancStoneSdlParameters.cmake Sat Jan 29 12:51:51 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,44 +0,0 @@ -# Stone of Orthanc -# Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics -# Department, University Hospital of Liege, Belgium -# Copyright (C) 2017-2022 Osimis S.A., Belgium -# Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium -# -# This program is free software: you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public License -# as published by the Free Software Foundation, either version 3 of -# the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this program. If not, see -# <http://www.gnu.org/licenses/>. - - - - -##################################################################### -## Load generic parameters -##################################################################### - -include(${CMAKE_CURRENT_LIST_DIR}/../../../OrthancStone/Resources/CMake/OrthancStoneParameters.cmake) - - -##################################################################### -## CMake parameters tunable by the user -##################################################################### - -# Advanced parameters to fine-tune linking against system libraries -set(USE_SYSTEM_SDL ON CACHE BOOL "Use the system version of SDL2") - - -##################################################################### -## Internal CMake parameters to enable the optional subcomponents of -## the Stone of Orthanc -##################################################################### - -set(ENABLE_THREADS ON CACHE INTERNAL "")
--- a/OrthancStone/Sources/Platforms/Sdl/SdlConfiguration.cmake Sat Jan 29 12:51:51 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,226 +0,0 @@ -# Stone of Orthanc -# Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics -# Department, University Hospital of Liege, Belgium -# Copyright (C) 2017-2022 Osimis S.A., Belgium -# Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium -# -# This program is free software: you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public License -# as published by the Free Software Foundation, either version 3 of -# the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this program. If not, see -# <http://www.gnu.org/licenses/>. - - -if (STATIC_BUILD OR NOT USE_SYSTEM_SDL) - SET(SDL_SOURCES_DIR ${CMAKE_BINARY_DIR}/SDL2-2.0.4) - SET(SDL_URL "http://orthanc.osimis.io/ThirdPartyDownloads/SDL2-2.0.4.tar.gz") - SET(SDL_MD5 "44fc4a023349933e7f5d7a582f7b886e") - DownloadPackage(${SDL_MD5} ${SDL_URL} "${SDL_SOURCES_DIR}") - - include_directories(${SDL_SOURCES_DIR}/include) - - set(TMP "${SDL_SOURCES_DIR}/include/SDL_config_premake.h") - if (NOT EXISTS "${TMP}") - file(WRITE "${TMP}" " -#include \"SDL_platform.h\" -#define HAVE_STDARG_H 1 -#define HAVE_STDDEF_H 1 -#define HAVE_STDINT_H 1 -") - endif() - - # General source files - file(GLOB SDL_SOURCES - ${SDL_SOURCES_DIR}/src/*.c - ${SDL_SOURCES_DIR}/src/atomic/*.c - ${SDL_SOURCES_DIR}/src/audio/*.c - ${SDL_SOURCES_DIR}/src/cpuinfo/*.c - ${SDL_SOURCES_DIR}/src/dynapi/*.c - ${SDL_SOURCES_DIR}/src/events/*.c - ${SDL_SOURCES_DIR}/src/file/*.c - ${SDL_SOURCES_DIR}/src/haptic/*.c - ${SDL_SOURCES_DIR}/src/joystick/*.c - ${SDL_SOURCES_DIR}/src/libm/*.c - ${SDL_SOURCES_DIR}/src/power/*.c - ${SDL_SOURCES_DIR}/src/render/*.c - ${SDL_SOURCES_DIR}/src/stdlib/*.c - ${SDL_SOURCES_DIR}/src/thread/*.c - ${SDL_SOURCES_DIR}/src/timer/*.c - ${SDL_SOURCES_DIR}/src/video/*.c - - ${SDL_SOURCES_DIR}/src/loadso/dummy/*.c - #${SDL_SOURCES_DIR}/src/timer/dummy/*.c - ${SDL_SOURCES_DIR}/src/audio/dummy/*.c - ${SDL_SOURCES_DIR}/src/filesystem/dummy/*.c - ${SDL_SOURCES_DIR}/src/haptic/dummy/*.c - ${SDL_SOURCES_DIR}/src/joystick/dummy/*.c - #${SDL_SOURCES_DIR}/src/main/dummy/*.c - ${SDL_SOURCES_DIR}/src/video/dummy/*.c - ) - - add_definitions( - -DUSING_PREMAKE_CONFIG_H=1 - - -DSDL_AUDIO_DISABLED=1 - -DSDL_AUDIO_DRIVER_DUMMY=1 - -DSDL_FILESYSTEM_DISABLED=1 - -DSDL_FILESYSTEM_DUMMY=1 - -DSDL_FILE_DISABLED=1 - -DSDL_HAPTIC_DISABLED=1 - -DSDL_JOYSTICK_DISABLED=1 - - #-DSDL_THREADS_DISABLED=1 - ) - - if (CMAKE_SYSTEM_NAME STREQUAL "Linux") - file(GLOB TMP - ${SDL_SOURCES_DIR}/src/core/linux/*.c - ${SDL_SOURCES_DIR}/src/loadso/dlopen/*.c - ${SDL_SOURCES_DIR}/src/render/software/*.c - ${SDL_SOURCES_DIR}/src/thread/pthread/*.c - ${SDL_SOURCES_DIR}/src/timer/unix/*.c - ${SDL_SOURCES_DIR}/src/video/x11/*.c - ) - - list(APPEND SDL_SOURCES ${TMP}) - - add_definitions( - -DSDL_LOADSO_DLOPEN=1 - -DSDL_THREAD_PTHREAD=1 - -DSDL_TIMER_UNIX=1 - -DSDL_POWER_DISABLED=1 - - -DSDL_VIDEO_DRIVER_X11=1 - - -DSDL_ASSEMBLY_ROUTINES=1 - -DSDL_THREAD_PTHREAD_RECURSIVE_MUTEX=1 - -DSDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS=1 - -DHAVE_GCC_SYNC_LOCK_TEST_AND_SET=1 - ) - - link_libraries(X11 Xext) - - if (NOT CMAKE_SYSTEM_VERSION STREQUAL "Raspberry") - # Raspberry Pi has no support for OpenGL - file(GLOB TMP - ${SDL_SOURCES_DIR}/src/render/opengl/*.c - ${SDL_SOURCES_DIR}/src/render/opengles2/*.c - ) - - list(APPEND SDL_SOURCES ${TMP}) - - add_definitions( - -DSDL_VIDEO_OPENGL=1 - -DSDL_VIDEO_OPENGL_ES2=1 - -DSDL_VIDEO_RENDER_OGL=1 - -DSDL_VIDEO_RENDER_OGL_ES2=1 - -DSDL_VIDEO_OPENGL_GLX=1 - -DSDL_VIDEO_OPENGL_EGL=1 - ) - endif() - - elseif (CMAKE_SYSTEM_NAME STREQUAL "Windows") - file(GLOB TMP - ${SDL_SOURCES_DIR}/src/audio/directsound/*.c - ${SDL_SOURCES_DIR}/src/audio/disk/*.c - ${SDL_SOURCES_DIR}/src/audio/winmm/*.c - ${SDL_SOURCES_DIR}/src/joystick/windows/*.c - ${SDL_SOURCES_DIR}/src/haptic/windows/*.c - ${SDL_SOURCES_DIR}/src/power/windows/*.c - - ${SDL_SOURCES_DIR}/src/main/windows/*.c - ${SDL_SOURCES_DIR}/src/core/windows/*.c - ${SDL_SOURCES_DIR}/src/loadso/windows/*.c - ${SDL_SOURCES_DIR}/src/render/direct3d/*.c - ${SDL_SOURCES_DIR}/src/render/direct3d11/*.c - ${SDL_SOURCES_DIR}/src/render/opengl/*.c - ${SDL_SOURCES_DIR}/src/render/psp/*.c - ${SDL_SOURCES_DIR}/src/render/opengles/*.c - ${SDL_SOURCES_DIR}/src/render/opengles2/*.c - ${SDL_SOURCES_DIR}/src/render/software/*.c - ${SDL_SOURCES_DIR}/src/thread/generic/SDL_syscond.c # Don't include more files from "thread/generic/*.c"! - ${SDL_SOURCES_DIR}/src/thread/windows/*.c - ${SDL_SOURCES_DIR}/src/timer/windows/*.c - ${SDL_SOURCES_DIR}/src/video/windows/*.c - ${SDL_SOURCES_DIR}/src/windows/dlopen/*.c - ) - - list(APPEND SDL_SOURCES ${TMP}) - - # NB: OpenGL ES headers are not available in MinGW-W64 - add_definitions( - -DSDL_LOADSO_WINDOWS=1 - -DSDL_THREAD_WINDOWS=1 - -DSDL_TIMER_WINDOWS=1 - -DSDL_POWER_WINDOWS=1 - - -DSDL_VIDEO_OPENGL=1 - -DSDL_VIDEO_OPENGL_WGL=1 - -DSDL_VIDEO_RENDER_D3D=1 - -DSDL_VIDEO_RENDER_OGL=1 - -DSDL_VIDEO_DRIVER_WINDOWS=1 - ) - - if (MSVC) - add_definitions( - -D__FLTUSED__ - -DHAVE_LIBC=1 - ) - else() - add_definitions( - -DHAVE_GCC_ATOMICS=1 - -DSDL_ASSEMBLY_ROUTINES=1 - ) - endif() - - link_libraries(imm32 winmm version) - - elseif (CMAKE_SYSTEM_NAME STREQUAL "Darwin") - file(GLOB TMP - ${SDL_SOURCES_DIR}/src/loadso/dlopen/*.c - ${SDL_SOURCES_DIR}/src/render/opengl/*.c - ${SDL_SOURCES_DIR}/src/render/opengles2/*.c - ${SDL_SOURCES_DIR}/src/render/software/*.c - ${SDL_SOURCES_DIR}/src/thread/pthread/*.c - ${SDL_SOURCES_DIR}/src/timer/unix/*.c - ${SDL_SOURCES_DIR}/src/video/cocoa/*.m - ) - - list(APPEND SDL_SOURCES ${TMP}) - - add_definitions( - -DSDL_LOADSO_DLOPEN=1 - -DSDL_THREAD_PTHREAD=1 - -DSDL_TIMER_UNIX=1 - -DSDL_POWER_DISABLED=1 - - -DSDL_VIDEO_DRIVER_COCOA=1 - -DSDL_VIDEO_OPENGL=1 - -DSDL_VIDEO_OPENGL_CGL=1 - -DSDL_VIDEO_RENDER_OGL=1 - - -DSDL_ASSEMBLY_ROUTINES=1 - -DSDL_THREAD_PTHREAD_RECURSIVE_MUTEX=1 - ) - - find_library(CARBON_LIBRARY Carbon) - find_library(COCOA_LIBRARY Cocoa) - find_library(IOKIT_LIBRARY IOKit) - find_library(QUARTZ_LIBRARY QuartzCore) - link_libraries(${CARBON_LIBRARY} ${COCOA_LIBRARY} ${IOKIT_LIBRARY} ${QUARTZ_LIBRARY}) - - endif() - -else() - pkg_search_module(SDL2 REQUIRED sdl2) - include_directories(${SDL2_INCLUDE_DIRS}) - link_libraries(${SDL2_LIBRARIES}) -endif()
--- a/OrthancStone/Sources/Platforms/Sdl/SdlOpenGLContext.cpp Sat Jan 29 12:51:51 2022 +0100 +++ b/OrthancStone/Sources/Platforms/Sdl/SdlOpenGLContext.cpp Sat Jan 29 16:55:14 2022 +0100 @@ -21,7 +21,7 @@ **/ #include "SdlOpenGLContext.h" -#include "../../../OrthancStone/Sources/StoneException.h" +#include "../../StoneException.h" #if ORTHANC_ENABLE_SDL == 1
--- a/OrthancStone/Sources/Platforms/Sdl/SdlOpenGLContext.h Sat Jan 29 12:51:51 2022 +0100 +++ b/OrthancStone/Sources/Platforms/Sdl/SdlOpenGLContext.h Sat Jan 29 16:55:14 2022 +0100 @@ -24,7 +24,7 @@ #if ORTHANC_ENABLE_SDL == 1 -#include "../../../OrthancStone/Sources/OpenGL/IOpenGLContext.h" +#include "../../OpenGL/IOpenGLContext.h" #include "SdlWindow.h" #include <Compatibility.h> // For ORTHANC_OVERRIDE
--- a/OrthancStone/Sources/Platforms/Sdl/SdlViewport.cpp Sat Jan 29 12:51:51 2022 +0100 +++ b/OrthancStone/Sources/Platforms/Sdl/SdlViewport.cpp Sat Jan 29 16:55:14 2022 +0100 @@ -22,7 +22,7 @@ #include "SdlViewport.h" -#include "../../../OrthancStone/Sources/Scene2DViewport/ViewportController.h" +#include "../../Scene2DViewport/ViewportController.h" #include <OrthancException.h>
--- a/OrthancStone/Sources/Platforms/Sdl/SdlViewport.h Sat Jan 29 12:51:51 2022 +0100 +++ b/OrthancStone/Sources/Platforms/Sdl/SdlViewport.h Sat Jan 29 16:55:14 2022 +0100 @@ -35,11 +35,11 @@ #endif #include "SdlOpenGLContext.h" -#include "../../../OrthancStone/Sources/Scene2D/CairoCompositor.h" -#include "../../../OrthancStone/Sources/Viewport/IViewport.h" +#include "../../Scene2D/CairoCompositor.h" +#include "../../Viewport/IViewport.h" #if ORTHANC_ENABLE_OPENGL == 1 -# include "../../../OrthancStone/Sources/Scene2D/OpenGLCompositor.h" +# include "../../Scene2D/OpenGLCompositor.h" #endif #include <SDL_events.h>
--- a/OrthancStone/Sources/Platforms/WebAssembly/OrthancStoneWebAssemblyConfiguration.cmake Sat Jan 29 12:51:51 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,62 +0,0 @@ -# Stone of Orthanc -# Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics -# Department, University Hospital of Liege, Belgium -# Copyright (C) 2017-2022 Osimis S.A., Belgium -# Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium -# -# This program is free software: you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public License -# as published by the Free Software Foundation, either version 3 of -# the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this program. If not, see -# <http://www.gnu.org/licenses/>. - - - - -##################################################################### -## Sanity check of the configuration -##################################################################### - -set(ENABLE_WEB_CLIENT OFF) -include(${ORTHANC_STONE_ROOT}/../Resources/CMake/OrthancStoneConfiguration.cmake) - -if (NOT ORTHANC_SANDBOXED) - message(FATAL_ERROR "WebAssembly target must me configured as sandboxed") -endif() - -if (NOT CMAKE_SYSTEM_NAME STREQUAL "Emscripten") - message(FATAL_ERROR "WebAssembly target requires the emscripten compiler") -endif() - -add_definitions( - -DORTHANC_ENABLE_SDL=0 - -DORTHANC_ENABLE_WASM=1 - ) - - -##################################################################### -## Additional source files for WebAssembly -##################################################################### - -list(APPEND ORTHANC_STONE_SOURCES - ${CMAKE_CURRENT_LIST_DIR}/WebAssemblyCairoViewport.cpp - ${CMAKE_CURRENT_LIST_DIR}/WebAssemblyLoadersContext.cpp - ${CMAKE_CURRENT_LIST_DIR}/WebAssemblyOracle.cpp - ${CMAKE_CURRENT_LIST_DIR}/WebAssemblyViewport.cpp - ) - -if (ENABLE_OPENGL) - list(APPEND ORTHANC_STONE_SOURCES - ${CMAKE_CURRENT_LIST_DIR}/WebAssemblyOpenGLContext.cpp - ${CMAKE_CURRENT_LIST_DIR}/WebGLViewport.cpp - ${CMAKE_CURRENT_LIST_DIR}/WebGLViewportsRegistry.cpp - ) -endif()
--- a/OrthancStone/Sources/Platforms/WebAssembly/OrthancStoneWebAssemblyParameters.cmake Sat Jan 29 12:51:51 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,43 +0,0 @@ -# Stone of Orthanc -# Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics -# Department, University Hospital of Liege, Belgium -# Copyright (C) 2017-2022 Osimis S.A., Belgium -# Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium -# -# This program is free software: you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public License -# as published by the Free Software Foundation, either version 3 of -# the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this program. If not, see -# <http://www.gnu.org/licenses/>. - - - - -##################################################################### -## Load generic parameters -##################################################################### - -include(${CMAKE_CURRENT_LIST_DIR}/../../../OrthancStone/Resources/CMake/OrthancStoneParameters.cmake) - - -##################################################################### -## CMake parameters tunable by the user -##################################################################### - -# None for now, but might contain stuff like memory settings - - -##################################################################### -## Internal CMake parameters to enable the optional subcomponents of -## the Stone of Orthanc -##################################################################### - -set(ENABLE_THREADS OFF CACHE INTERNAL "")
--- a/OrthancStone/Sources/Platforms/WebAssembly/SharedLibrary/CMakeLists.txt Sat Jan 29 12:51:51 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,213 +0,0 @@ -# Stone of Orthanc -# Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics -# Department, University Hospital of Liege, Belgium -# Copyright (C) 2017-2022 Osimis S.A., Belgium -# Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium -# -# This program is free software: you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public License -# as published by the Free Software Foundation, either version 3 of -# the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this program. If not, see -# <http://www.gnu.org/licenses/>. - - - -cmake_minimum_required(VERSION 2.8.3) -cmake_policy(SET CMP0058 NEW) - -project(OrthancStoneModule) - - -# Warning message related to WebAssembly modules: We know that 1.38.41 -# DOES NOT work, but that 1.39.17 works. -message("") -message("=== IMPORTANT: Make sure to use a recent version of Emscripten (preferably >= 2.0.0) ===") -message("") - - -set(ORTHANC_STONE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}/../../../../wasm-binaries/OrthancStoneModule" CACHE PATH "Where to put the WebAssembly binaries") - - -# Ask for the generation of a side module -set(WASM_FLAGS "-s SIDE_MODULE=1 -s EXPORT_ALL=1") # Must be before "Compiler.cmake" - - -# Configuration of the Emscripten compiler for WebAssembly target -# --------------------------------------------------------------- - -set(USE_WASM ON CACHE BOOL "") - -set(WASM_FLAGS "${WASM_FLAGS} -s WASM=1 -s FETCH=1") -if (CMAKE_BUILD_TYPE STREQUAL "Debug") - set(WASM_FLAGS "${WASM_FLAGS} -s SAFE_HEAP=1") -endif() - -set(WASM_LINKER_FLAGS "${WASM_LINKER_FLAGS} -s ASSERTIONS=1 -s DISABLE_EXCEPTION_CATCHING=0") -set(WASM_LINKER_FLAGS "${WASM_LINKER_FLAGS} -s DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1") -add_definitions( - -DDISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1 -) - - -# Stone of Orthanc configuration -# --------------------------------------------------------------- - -include(${CMAKE_SOURCE_DIR}/../OrthancStoneWebAssemblyParameters.cmake) - -SET(ENABLE_DCMTK ON) -SET(ENABLE_DCMTK_NETWORKING OFF) -SET(ENABLE_DCMTK_TRANSCODING OFF) -SET(ENABLE_GOOGLE_TEST OFF) -SET(ENABLE_LOCALE ON) # Necessary for text rendering -SET(ORTHANC_SANDBOXED ON) - -include(${CMAKE_SOURCE_DIR}/../OrthancStoneWebAssemblyConfiguration.cmake) - - - - -################################################################################ - -# The source files that register a callback cannot be part of a side -# module, and must be compiled in the main module. The following -# command can be used to identify such files: -# $ grep -lrE 'emscripten_' ../../Sources/ - -set(SOURCES_WITH_EMSCRIPTEN_CALLBACKS - ${CMAKE_SOURCE_DIR}/../WebAssemblyOracle.cpp - ${CMAKE_SOURCE_DIR}/../WebAssemblyViewport.cpp - ${CMAKE_SOURCE_DIR}/../WebAssemblyCairoViewport.cpp - ) - -list(REMOVE_ITEM ORTHANC_STONE_SOURCES - ${SOURCES_WITH_EMSCRIPTEN_CALLBACKS} - ) - -configure_file( - ${ORTHANC_STONE_ROOT}/../SharedLibrary/OrthancStone.h.in - ${CMAKE_CURRENT_BINARY_DIR}/Include/orthanc-stone/OrthancStone.h - ) - -configure_file( - ${ORTHANC_FRAMEWORK_ROOT}/../SharedLibrary/OrthancFramework.h.in - ${CMAKE_CURRENT_BINARY_DIR}/Include/orthanc-framework/OrthancFramework.h - ) - -file( - COPY ${CMAKE_SOURCE_DIR}/../../../../OrthancStone/Sources/ - DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/Include/orthanc-stone - NO_SOURCE_PERMISSIONS - FILES_MATCHING - PATTERN "*.h" - PATTERN OrthancStone.h EXCLUDE - PATTERN "Deprecated*" EXCLUDE - ) - -file( - COPY ${ORTHANC_FRAMEWORK_ROOT}/ - DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/Include/orthanc-framework - NO_SOURCE_PERMISSIONS - FILES_MATCHING - PATTERN "*.h" - PATTERN OrthancFramework.h EXCLUDE - ) - -add_executable(OrthancStoneModule - ${ORTHANC_STONE_SOURCES} - ${AUTOGENERATED_SOURCES} - ${CAIRO_SOURCES} - ${PIXMAN_SOURCES} - ${FREETYPE_SOURCES} - ) - -set_target_properties(OrthancStoneModule - PROPERTIES - COMPILE_FLAGS "${WASM_FLAGS}" - LINK_FLAGS "${WASM_LINKER_FLAGS}" - ) - -# CMake does not natively handle SIDE_MODULE, and believes that -# Emscripten produces a ".js" file (whereas it creates only the -# ".wasm"). Create a dummy ".js" for target to work. -add_custom_command( - TARGET OrthancStoneModule POST_BUILD - COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/OrthancStoneModule.js - ) - -file( - COPY ${BOOST_SOURCES_DIR}/boost/ - DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/Include/boost/ - NO_SOURCE_PERMISSIONS - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "*.ipp" - ) - -file( - COPY ${JSONCPP_SOURCES_DIR}/include/json/ - DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/Include/json/ - NO_SOURCE_PERMISSIONS - FILES_MATCHING - PATTERN "*.h" - ) - -file( - COPY ${CAIRO_SOURCES_DIR}/src/ - DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/Include/cairo/ - NO_SOURCE_PERMISSIONS - FILES_MATCHING - PATTERN "*.h" - ) - -set(DCMTK_MODULES - dcmdata - config - ofstd - oflog - ) - -foreach (module IN LISTS DCMTK_MODULES) - file( - COPY ${DCMTK_SOURCES_DIR}/ofstd/include/dcmtk/${module}/ - DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/Include/dcmtk/${module}/ - NO_SOURCE_PERMISSIONS - FILES_MATCHING - PATTERN "*.h" - ) -endforeach() - - -install( - TARGETS OrthancStoneModule - DESTINATION ${ORTHANC_STONE_INSTALL_PREFIX}/lib - ) - -install(FILES - ${CMAKE_CURRENT_BINARY_DIR}/OrthancStoneModule.wasm - DESTINATION ${ORTHANC_STONE_INSTALL_PREFIX}/lib - ) - -install( - DIRECTORY - ${CMAKE_CURRENT_BINARY_DIR}/Include/boost - ${CMAKE_CURRENT_BINARY_DIR}/Include/cairo - ${CMAKE_CURRENT_BINARY_DIR}/Include/dcmtk - ${CMAKE_CURRENT_BINARY_DIR}/Include/json - ${CMAKE_CURRENT_BINARY_DIR}/Include/orthanc-framework - ${CMAKE_CURRENT_BINARY_DIR}/Include/orthanc-stone - DESTINATION ${ORTHANC_STONE_INSTALL_PREFIX}/include/ - ) - -install(FILES - ${SOURCES_WITH_EMSCRIPTEN_CALLBACKS} - DESTINATION ${ORTHANC_STONE_INSTALL_PREFIX}/src/orthanc-stone - )
--- a/OrthancStone/Sources/Platforms/WebAssembly/SharedLibrary/NOTES.txt Sat Jan 29 12:51:51 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,18 +0,0 @@ - -Install Emscripten: -https://emscripten.org/docs/getting_started/downloads.html - -# cd ~/Downloads -# git clone https://github.com/emscripten-core/emsdk.git -# cd emsdk -# ./emsdk install 2.0.0 -# ./emsdk activate 2.0.0 - - -Then, if the installation path was "~/Downloads/emsdk/": - -# source ~/Downloads/emsdk/emsdk_env.sh -# cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=${EMSDK}/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake -DALLOW_DOWNLOADS=ON -G Ninja -# ninja install - -=> The binaries will be put in "../../../../wasm-binaries/"
--- a/OrthancStone/Sources/Platforms/WebAssembly/UnitTests/CMakeLists.txt Sat Jan 29 12:51:51 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,139 +0,0 @@ -# Stone of Orthanc -# Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics -# Department, University Hospital of Liege, Belgium -# Copyright (C) 2017-2022 Osimis S.A., Belgium -# Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium -# -# This program is free software: you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public License -# as published by the Free Software Foundation, either version 3 of -# the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this program. If not, see -# <http://www.gnu.org/licenses/>. - - - -cmake_minimum_required(VERSION 2.8.3) -cmake_policy(SET CMP0058 NEW) - -project(OrthancStone) - -set(ORTHANC_FRAMEWORK_DEFAULT_VERSION "mainline") -set(ORTHANC_FRAMEWORK_DEFAULT_SOURCE "hg") -set(ORTHANC_STONE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}/../../../../wasm-binaries/" CACHE PATH "Where to put the WebAssembly binaries") - - -# Configuration of the Emscripten compiler for WebAssembly target -# --------------------------------------------------------------- -set(USE_WASM ON CACHE BOOL "") - -set(WASM_FLAGS "-s WASM=1 -s FETCH=1 -s ASSERTIONS=1 -s DISABLE_EXCEPTION_CATCHING=0") -if (CMAKE_BUILD_TYPE STREQUAL "Debug") - set(WASM_FLAGS "${WASM_FLAGS} -s SAFE_HEAP=1") -endif() - -set(WASM_LINKER_FLAGS "${WASM_LINKER_FLAGS} -s EXTRA_EXPORTED_RUNTIME_METHODS='[\"ccall\", \"cwrap\"]'") -set(WASM_LINKER_FLAGS "${WASM_LINKER_FLAGS} -s ERROR_ON_UNDEFINED_SYMBOLS=1") -set(WASM_LINKER_FLAGS "${WASM_LINKER_FLAGS} -s ALLOW_MEMORY_GROWTH=1 -s TOTAL_MEMORY=268435456") # 256MB + resize -set(WASM_LINKER_FLAGS "${WASM_LINKER_FLAGS} -s DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1") -add_definitions( - -DDISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1 -) - - -# Stone of Orthanc configuration -# --------------------------------------------------------------- -set(ALLOW_DOWNLOADS ON) - -include(${CMAKE_SOURCE_DIR}/../OrthancStoneWebAssemblyParameters.cmake) - -SET(ENABLE_DCMTK ON) # Necessary for the tests of the Orthanc framework -SET(ENABLE_PUGIXML ON) # Necessary for the tests of the Orthanc framework -SET(ENABLE_GOOGLE_TEST OFF) -SET(ENABLE_LOCALE ON) # Necessary for text rendering -SET(ENABLE_LUA ON) # Necessary for the tests of the Orthanc framework -SET(ORTHANC_SANDBOXED ON) - -# this will set up the build system for Stone of Orthanc and will -# populate the ORTHANC_STONE_SOURCES CMake variable -include(${CMAKE_SOURCE_DIR}/../OrthancStoneWebAssemblyConfiguration.cmake) - - -################################################################################ - -# Define the WASM module -# --------------------------------------------------------------- - -set(USE_SYSTEM_GOOGLE_TEST OFF CACHE BOOL "Use the system version of Google Test") -set(USE_GOOGLE_TEST_DEBIAN_PACKAGE OFF CACHE BOOL "Use the sources of Google Test shipped with libgtest-dev (Debian only)") -mark_as_advanced(USE_GOOGLE_TEST_DEBIAN_PACKAGE) -include(${ORTHANC_STONE_ROOT}/../Resources/Orthanc/CMake/DownloadPackage.cmake) -include(${ORTHANC_STONE_ROOT}/../Resources/Orthanc/CMake/GoogleTestConfiguration.cmake) - - -include(${CMAKE_SOURCE_DIR}/../../../../OrthancStone/UnitTestsSources/UnitTestsSources.cmake) - -EmbedResources( - RT_STRUCT_00 ${CMAKE_SOURCE_DIR}/../../../../OrthancStone/UnitTestsSources/TestStructureSet.json - ) - -add_executable(UnitTests - # Testing Stone - ${UNIT_TESTS_SOURCES} - - # Testing the Orthanc Framework - ${ORTHANC_FRAMEWORK_ROOT}/../UnitTestsSources/DicomMapTests.cpp - ${ORTHANC_FRAMEWORK_ROOT}/../UnitTestsSources/FrameworkTests.cpp - ${ORTHANC_FRAMEWORK_ROOT}/../UnitTestsSources/FromDcmtkTests.cpp - ${ORTHANC_FRAMEWORK_ROOT}/../UnitTestsSources/ImageProcessingTests.cpp - ${ORTHANC_FRAMEWORK_ROOT}/../UnitTestsSources/ImageTests.cpp - ${ORTHANC_FRAMEWORK_ROOT}/../UnitTestsSources/JpegLosslessTests.cpp - ${ORTHANC_FRAMEWORK_ROOT}/../UnitTestsSources/LoggingTests.cpp - ${ORTHANC_FRAMEWORK_ROOT}/../UnitTestsSources/LuaTests.cpp - ${ORTHANC_FRAMEWORK_ROOT}/../UnitTestsSources/RestApiTests.cpp - ${ORTHANC_FRAMEWORK_ROOT}/../UnitTestsSources/StreamTests.cpp - ${ORTHANC_FRAMEWORK_ROOT}/../UnitTestsSources/ToolboxTests.cpp - - # Tests that are not compatible with WebAssembly - - # ${ORTHANC_FRAMEWORK_ROOT}/../UnitTestsSources/FileStorageTests.cpp - # ${ORTHANC_FRAMEWORK_ROOT}/../UnitTestsSources/JobsTests.cpp - # ${ORTHANC_FRAMEWORK_ROOT}/../UnitTestsSources/MemoryCacheTests.cpp - # ${ORTHANC_FRAMEWORK_ROOT}/../UnitTestsSources/SQLiteChromiumTests.cpp - # ${ORTHANC_FRAMEWORK_ROOT}/../UnitTestsSources/SQLiteTests.cpp - # ${ORTHANC_FRAMEWORK_ROOT}/../UnitTestsSources/ZipTests.cpp - - # Shared files - ${AUTOGENERATED_SOURCES} - ${BOOST_EXTENDED_SOURCES} - ${GOOGLE_TEST_SOURCES} - ${ORTHANC_STONE_SOURCES} - ) - - -# Declare installation files for the module -# --------------------------------------------------------------- -install( - TARGETS UnitTests - RUNTIME DESTINATION ${ORTHANC_STONE_INSTALL_PREFIX}/UnitTests/ - ) - -# Declare installation files for the companion files (web scaffolding) -# please note that ${CMAKE_CURRENT_BINARY_DIR}/RtViewerWasm.js -# (the generated JS loader for the WASM module) is handled by the `install1` -# section above: it is considered to be the binary output of -# the linker. -# --------------------------------------------------------------- -install( - FILES - ${CMAKE_SOURCE_DIR}/index.html - ${CMAKE_CURRENT_BINARY_DIR}/UnitTests.wasm - DESTINATION ${ORTHANC_STONE_INSTALL_PREFIX}/UnitTests - )
--- a/OrthancStone/Sources/Platforms/WebAssembly/UnitTests/NOTES.txt Sat Jan 29 12:51:51 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,18 +0,0 @@ -Native compilation (without Docker) -=================================== - -Install Emscripten: -https://emscripten.org/docs/getting_started/downloads.html - -Then, if the installation path is "~/Downloads/emsdk/": - -# source ~/Downloads/emsdk/emsdk_env.sh -# mkdir Build && cd Build -# cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=${EMSDK}/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake -DALLOW_DOWNLOADS=ON -G Ninja -# ninja install - -=> The binaries will be put in "../../../../../wasm-binaries/UnitTests/" - -# cd `pwd`/../../../../../wasm-binaries/UnitTests -# python3 -m http.server 8000 -# firefox http://localhost:8000/index.html
--- a/OrthancStone/Sources/Platforms/WebAssembly/UnitTests/index.html Sat Jan 29 12:51:51 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,14 +0,0 @@ -<!DOCTYPE html> -<html lang="en"> - <head> - <meta charset="utf-8"> - <title>Stone of Orthanc</title> - </head> - <body> - <h1>Stone of Orthanc - Unit tests</h1> - <pre id="output"> - Running the tests... - </pre> - <script src="UnitTests.js" async></script> - </body> -</html>
--- a/OrthancStone/Sources/Platforms/WebAssembly/WebAssemblyCairoViewport.cpp Sat Jan 29 12:51:51 2022 +0100 +++ b/OrthancStone/Sources/Platforms/WebAssembly/WebAssemblyCairoViewport.cpp Sat Jan 29 16:55:14 2022 +0100 @@ -23,8 +23,8 @@ #if defined(ORTHANC_BUILDING_STONE_LIBRARY) && ORTHANC_BUILDING_STONE_LIBRARY == 1 # include "WebAssemblyCairoViewport.h" -# include "../../../OrthancStone/Sources/Scene2D/CairoCompositor.h" -# include "../../../OrthancStone/Sources/Scene2DViewport/ViewportController.h" +# include "../../Scene2D/CairoCompositor.h" +# include "../../Scene2DViewport/ViewportController.h" #else // This is the case when using the WebAssembly side module, and this // source file must be compiled within the WebAssembly main module
--- a/OrthancStone/Sources/Platforms/WebAssembly/WebAssemblyLoadersContext.h Sat Jan 29 12:51:51 2022 +0100 +++ b/OrthancStone/Sources/Platforms/WebAssembly/WebAssemblyLoadersContext.h Sat Jan 29 16:55:14 2022 +0100 @@ -23,8 +23,8 @@ #pragma once -#include "../../../OrthancStone/Sources/Loaders/ILoadersContext.h" -#include "../../../OrthancStone/Sources/Loaders/OracleScheduler.h" +#include "../../Loaders/ILoadersContext.h" +#include "../../Loaders/OracleScheduler.h" #include "WebAssemblyOracle.h" #include <list>
--- a/OrthancStone/Sources/Platforms/WebAssembly/WebAssemblyOpenGLContext.cpp Sat Jan 29 12:51:51 2022 +0100 +++ b/OrthancStone/Sources/Platforms/WebAssembly/WebAssemblyOpenGLContext.cpp Sat Jan 29 16:55:14 2022 +0100 @@ -23,7 +23,7 @@ #include "WebAssemblyOpenGLContext.h" -#include "../../../OrthancStone/Sources/StoneException.h" +#include "../../StoneException.h" #include <Logging.h> #include <OrthancException.h>
--- a/OrthancStone/Sources/Platforms/WebAssembly/WebAssemblyOpenGLContext.h Sat Jan 29 12:51:51 2022 +0100 +++ b/OrthancStone/Sources/Platforms/WebAssembly/WebAssemblyOpenGLContext.h Sat Jan 29 16:55:14 2022 +0100 @@ -39,7 +39,7 @@ # error Support for OpenGL is disabled #endif -#include "../../../OrthancStone/Sources/OpenGL/IOpenGLContext.h" +#include "../../OpenGL/IOpenGLContext.h" #include <Compatibility.h> // For ORTHANC_OVERRIDE
--- a/OrthancStone/Sources/Platforms/WebAssembly/WebAssemblyOracle.h Sat Jan 29 12:51:51 2022 +0100 +++ b/OrthancStone/Sources/Platforms/WebAssembly/WebAssemblyOracle.h Sat Jan 29 16:55:14 2022 +0100 @@ -23,7 +23,7 @@ #pragma once -#include "../../../OrthancStone/Sources/OrthancStone.h" +#include "../../OrthancStone.h" #if !defined(ORTHANC_ENABLE_WASM) # error The macro ORTHANC_ENABLE_WASM must be defined @@ -33,12 +33,12 @@ # error This file can only compiled for WebAssembly #endif -#include "../../../OrthancStone/Sources/Messages/IObservable.h" -#include "../../../OrthancStone/Sources/Messages/IMessageEmitter.h" -#include "../../../OrthancStone/Sources/Oracle/IOracle.h" +#include "../../Messages/IObservable.h" +#include "../../Messages/IMessageEmitter.h" +#include "../../Oracle/IOracle.h" #if ORTHANC_ENABLE_DCMTK == 1 -# include "../../../OrthancStone/Sources/Toolbox/ParsedDicomCache.h" +# include "../../Toolbox/ParsedDicomCache.h" #endif #include <Compatibility.h> // For ORTHANC_OVERRIDE
--- a/OrthancStone/Sources/Platforms/WebAssembly/WebAssemblyOracle_Includes.h Sat Jan 29 12:51:51 2022 +0100 +++ b/OrthancStone/Sources/Platforms/WebAssembly/WebAssemblyOracle_Includes.h Sat Jan 29 16:55:14 2022 +0100 @@ -30,15 +30,15 @@ #include "WebAssemblyOracle.h" -#include "../../../OrthancStone/Sources/Oracle/OracleCommandExceptionMessage.h" +#include "../../Oracle/OracleCommandExceptionMessage.h" #if ORTHANC_ENABLE_DCMTK == 1 -# include "../../../OrthancStone/Sources/Oracle/ParseDicomSuccessMessage.h" +# include "../../Oracle/ParseDicomSuccessMessage.h" #endif -#include "../../../OrthancStone/Sources/Oracle/GetOrthancImageCommand.h" -#include "../../../OrthancStone/Sources/Oracle/GetOrthancWebViewerJpegCommand.h" -#include "../../../OrthancStone/Sources/Oracle/HttpCommand.h" -#include "../../../OrthancStone/Sources/Oracle/OrthancRestApiCommand.h" -#include "../../../OrthancStone/Sources/Oracle/ParseDicomFromWadoCommand.h" -#include "../../../OrthancStone/Sources/Oracle/SleepOracleCommand.h" +#include "../../Oracle/GetOrthancImageCommand.h" +#include "../../Oracle/GetOrthancWebViewerJpegCommand.h" +#include "../../Oracle/HttpCommand.h" +#include "../../Oracle/OrthancRestApiCommand.h" +#include "../../Oracle/ParseDicomFromWadoCommand.h" +#include "../../Oracle/SleepOracleCommand.h"
--- a/OrthancStone/Sources/Platforms/WebAssembly/WebAssemblyViewport.cpp Sat Jan 29 12:51:51 2022 +0100 +++ b/OrthancStone/Sources/Platforms/WebAssembly/WebAssemblyViewport.cpp Sat Jan 29 16:55:14 2022 +0100 @@ -23,9 +23,9 @@ #if defined(ORTHANC_BUILDING_STONE_LIBRARY) && ORTHANC_BUILDING_STONE_LIBRARY == 1 # include "WebAssemblyViewport.h" -# include "../../../OrthancStone/Sources/Scene2DViewport/ViewportController.h" -# include "../../../OrthancStone/Sources/Toolbox/GenericToolbox.h" -# include "../../../OrthancStone/Sources/Viewport/DefaultViewportInteractor.h" +# include "../../Scene2DViewport/ViewportController.h" +# include "../../Toolbox/GenericToolbox.h" +# include "../../Viewport/DefaultViewportInteractor.h" #else // This is the case when using the WebAssembly side module, and this // source file must be compiled within the WebAssembly main module
--- a/OrthancStone/Sources/Platforms/WebAssembly/WebAssemblyViewport.h Sat Jan 29 12:51:51 2022 +0100 +++ b/OrthancStone/Sources/Platforms/WebAssembly/WebAssemblyViewport.h Sat Jan 29 16:55:14 2022 +0100 @@ -23,7 +23,7 @@ #pragma once -#include "../../../OrthancStone/Sources/OrthancStone.h" +#include "../../OrthancStone.h" #if !defined(ORTHANC_ENABLE_WASM) # error Macro ORTHANC_ENABLE_WASM must be defined @@ -33,8 +33,8 @@ # error This file can only be used if targeting WebAssembly #endif -#include "../../../OrthancStone/Sources/Viewport/IViewport.h" -#include "../../../OrthancStone/Sources/Viewport/IViewportInteractor.h" +#include "../../Viewport/IViewport.h" +#include "../../Viewport/IViewportInteractor.h" #include <Compatibility.h>
--- a/OrthancStone/Sources/Platforms/WebAssembly/WebGLViewport.cpp Sat Jan 29 12:51:51 2022 +0100 +++ b/OrthancStone/Sources/Platforms/WebAssembly/WebGLViewport.cpp Sat Jan 29 16:55:14 2022 +0100 @@ -23,9 +23,9 @@ #include "WebGLViewport.h" -#include "../../../OrthancStone/Sources/StoneException.h" -#include "../../../OrthancStone/Sources/Scene2D/OpenGLCompositor.h" -#include "../../../OrthancStone/Sources/Scene2DViewport/ViewportController.h" +#include "../../StoneException.h" +#include "../../Scene2D/OpenGLCompositor.h" +#include "../../Scene2DViewport/ViewportController.h" namespace OrthancStone {
--- a/OrthancStone/Sources/Platforms/WebAssembly/WebGLViewportsRegistry.cpp Sat Jan 29 12:51:51 2022 +0100 +++ b/OrthancStone/Sources/Platforms/WebAssembly/WebGLViewportsRegistry.cpp Sat Jan 29 16:55:14 2022 +0100 @@ -23,8 +23,8 @@ #include "WebGLViewportsRegistry.h" -#include "../../../OrthancStone/Sources/Scene2DViewport/ViewportController.h" -#include "../../../OrthancStone/Sources/Toolbox/GenericToolbox.h" +#include "../../Scene2DViewport/ViewportController.h" +#include "../../Toolbox/GenericToolbox.h" #include <OrthancException.h>