Mercurial > hg > orthanc-stone
comparison UnitTestsSources/WebAssembly/CMakeLists.txt @ 1679:5b8b88e5bfd6
successfully running unit tests in WebAssembly
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 24 Nov 2020 12:59:10 +0100 |
parents | |
children | 03afa09cfcf1 |
comparison
equal
deleted
inserted
replaced
1678:1393e3393a0b | 1679:5b8b88e5bfd6 |
---|---|
1 # Stone of Orthanc | |
2 # Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
3 # Department, University Hospital of Liege, Belgium | |
4 # Copyright (C) 2017-2020 Osimis S.A., Belgium | |
5 # | |
6 # This program is free software: you can redistribute it and/or | |
7 # modify it under the terms of the GNU Affero General Public License | |
8 # as published by the Free Software Foundation, either version 3 of | |
9 # the License, or (at your option) any later version. | |
10 # | |
11 # This program is distributed in the hope that it will be useful, but | |
12 # WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 # Affero General Public License for more details. | |
15 # | |
16 # You should have received a copy of the GNU Affero General Public License | |
17 # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
18 | |
19 | |
20 cmake_minimum_required(VERSION 2.8.3) | |
21 cmake_policy(SET CMP0058 NEW) | |
22 | |
23 project(OrthancStone) | |
24 | |
25 set(ORTHANC_STONE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}/../../wasm-binaries/" CACHE PATH "Where to put the WebAssembly binaries") | |
26 | |
27 | |
28 # Configuration of the Emscripten compiler for WebAssembly target | |
29 # --------------------------------------------------------------- | |
30 set(USE_WASM ON CACHE BOOL "") | |
31 | |
32 set(WASM_FLAGS "-s WASM=1 -s FETCH=1 -s ASSERTIONS=1 -s DISABLE_EXCEPTION_CATCHING=0") | |
33 if (CMAKE_BUILD_TYPE STREQUAL "Debug") | |
34 set(WASM_FLAGS "${WASM_FLAGS} -s SAFE_HEAP=1") | |
35 endif() | |
36 | |
37 set(WASM_LINKER_FLAGS "${WASM_LINKER_FLAGS} -s EXTRA_EXPORTED_RUNTIME_METHODS='[\"ccall\", \"cwrap\"]'") | |
38 set(WASM_LINKER_FLAGS "${WASM_LINKER_FLAGS} -s ERROR_ON_UNDEFINED_SYMBOLS=1") | |
39 set(WASM_LINKER_FLAGS "${WASM_LINKER_FLAGS} -s ALLOW_MEMORY_GROWTH=1 -s TOTAL_MEMORY=268435456") # 256MB + resize | |
40 set(WASM_LINKER_FLAGS "${WASM_LINKER_FLAGS} -s DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1") | |
41 add_definitions( | |
42 -DDISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1 | |
43 ) | |
44 | |
45 | |
46 # Stone of Orthanc configuration | |
47 # --------------------------------------------------------------- | |
48 set(ALLOW_DOWNLOADS ON) | |
49 | |
50 include(${CMAKE_SOURCE_DIR}/../../Applications/Platforms/WebAssembly/OrthancStoneWebAssemblyParameters.cmake) | |
51 | |
52 SET(ENABLE_DCMTK OFF) # Not necessary | |
53 SET(ENABLE_GOOGLE_TEST OFF) | |
54 SET(ENABLE_LOCALE ON) # Necessary for text rendering | |
55 SET(ORTHANC_SANDBOXED ON) | |
56 | |
57 # Needed to redirect std::cout to a <div> | |
58 set(ORTHANC_ENABLE_LOGGING_STDIO OFF CACHE INTERNAL "") | |
59 | |
60 # this will set up the build system for Stone of Orthanc and will | |
61 # populate the ORTHANC_STONE_SOURCES CMake variable | |
62 include(${CMAKE_SOURCE_DIR}/../../Applications/Platforms/WebAssembly/OrthancStoneWebAssemblyConfiguration.cmake) | |
63 | |
64 | |
65 ################################################################################ | |
66 | |
67 # Define the WASM module | |
68 # --------------------------------------------------------------- | |
69 | |
70 set(USE_SYSTEM_GOOGLE_TEST OFF CACHE BOOL "Use the system version of Google Test") | |
71 set(USE_GOOGLE_TEST_DEBIAN_PACKAGE OFF CACHE BOOL "Use the sources of Google Test shipped with libgtest-dev (Debian only)") | |
72 mark_as_advanced(USE_GOOGLE_TEST_DEBIAN_PACKAGE) | |
73 include(${ORTHANC_STONE_ROOT}/../Resources/Orthanc/CMake/DownloadPackage.cmake) | |
74 include(${ORTHANC_STONE_ROOT}/../Resources/Orthanc/CMake/GoogleTestConfiguration.cmake) | |
75 | |
76 | |
77 include(${CMAKE_SOURCE_DIR}/../UnitTestsSources.cmake) | |
78 add_executable(UnitTests ${UNIT_TESTS_SOURCES}) | |
79 | |
80 | |
81 # Declare installation files for the module | |
82 # --------------------------------------------------------------- | |
83 install( | |
84 TARGETS UnitTests | |
85 RUNTIME DESTINATION ${ORTHANC_STONE_INSTALL_PREFIX}/UnitTests/ | |
86 ) | |
87 | |
88 # Declare installation files for the companion files (web scaffolding) | |
89 # please note that ${CMAKE_CURRENT_BINARY_DIR}/RtViewerWasm.js | |
90 # (the generated JS loader for the WASM module) is handled by the `install1` | |
91 # section above: it is considered to be the binary output of | |
92 # the linker. | |
93 # --------------------------------------------------------------- | |
94 install( | |
95 FILES | |
96 ${CMAKE_SOURCE_DIR}/index.html | |
97 ${CMAKE_CURRENT_BINARY_DIR}/UnitTests.wasm | |
98 DESTINATION ${ORTHANC_STONE_INSTALL_PREFIX}/UnitTests | |
99 ) |