diff Applications/Platforms/WebAssembly/UnitTests/CMakeLists.txt @ 1879:b4486f43394a

reorganization
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 12 Jan 2022 09:06:31 +0100
parents OrthancStone/UnitTestsSources/WebAssembly/CMakeLists.txt@a2955abe4c2e
children a05529952510
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Applications/Platforms/WebAssembly/UnitTests/CMakeLists.txt	Wed Jan 12 09:06:31 2022 +0100
@@ -0,0 +1,132 @@
+# 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 Affero 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
+# Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero 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)
+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
+  )