view OrthancStone/Resources/WebAssemblyUnitTests/CMakeLists.txt @ 2147:bea4e7900a47

upgraded jquery to 3.7.1 & axios to 1.7.5
author Alain Mazy <am@orthanc.team>
date Mon, 26 Aug 2024 17:59:20 +0200
parents 16c01cc201e7
children 2e050ec85379
line wrap: on
line source

# Stone of Orthanc
# Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
# Department, University Hospital of Liege, Belgium
# Copyright (C) 2017-2023 Osimis S.A., Belgium
# Copyright (C) 2021-2024 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 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
  -DORTHANC_BUILD_UNIT_TESTS=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_GOOGLE_TEST OFF)
SET(ENABLE_LOCALE ON)  # Necessary for text rendering
SET(ENABLE_LUA ON)     # Necessary for the tests of the Orthanc framework
SET(ENABLE_MODULE_JOBS OFF)
SET(ENABLE_PUGIXML 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}
  )

# Boost::Math begs for -std=c++14 since Boost 1.82.0
set_property(TARGET UnitTests PROPERTY CXX_STANDARD 14)

if (COMMAND DefineSourceBasenameForTarget)
  DefineSourceBasenameForTarget(UnitTests)
endif()

  
# 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
  )