comparison OrthancFramework/Resources/CMake/WebAssembly/ArithmeticTests/CMakeLists.txt @ 4044:d25f4c0fa160 framework

splitting code into OrthancFramework and OrthancServer
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 10 Jun 2020 20:30:34 +0200
parents Resources/WebAssembly/ArithmeticTests/CMakeLists.txt@2b81d44e7b33
children 47e9e788224c
comparison
equal deleted inserted replaced
4043:6c6239aec462 4044:d25f4c0fa160
1 # source ~/Downloads/emsdk-portable/emsdk_env.sh
2 # cmake .. -DCMAKE_TOOLCHAIN_FILE=${EMSCRIPTEN}/cmake/Modules/Platform/Emscripten.cmake \
3 # -DCMAKE_BUILD_TYPE=Debug \
4 # -DCMAKE_INSTALL_PREFIX=/tmp/wasm-install/
5 # make install
6 # -> Open the "/tmp/wasm-install/" with Firefox by serving it through Apache
7 # -> Copy the result as "../arith.h"
8
9
10 cmake_minimum_required(VERSION 2.8.3)
11
12
13 #####################################################################
14 ## Configuration of the Emscripten compiler for WebAssembly target
15 #####################################################################
16
17 set(WASM_FLAGS "-s WASM=1 -s DISABLE_EXCEPTION_CATCHING=0")
18 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WASM_FLAGS}")
19 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WASM_FLAGS}")
20
21 # Turn on support for debug exceptions
22 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s DISABLE_EXCEPTION_CATCHING=0")
23
24
25 #####################################################################
26 ## Prepare DCMTK 3.6.2
27 #####################################################################
28
29 set(ORTHANC_ROOT ${CMAKE_SOURCE_DIR}/../../..)
30 include(${ORTHANC_ROOT}/Resources/CMake/Compiler.cmake)
31 include(${ORTHANC_ROOT}/Resources/CMake/DownloadPackage.cmake)
32
33 set(DCMTK_SOURCES_DIR ${CMAKE_BINARY_DIR}/dcmtk-3.6.2)
34 set(DCMTK_URL "http://orthanc.osimis.io/ThirdPartyDownloads/dcmtk-3.6.2.tar.gz")
35 set(DCMTK_MD5 "d219a4152772985191c9b89d75302d12")
36
37 if (IS_DIRECTORY "${DCMTK_SOURCES_DIR}")
38 set(FirstRun OFF)
39 else()
40 set(FirstRun ON)
41 endif()
42
43 DownloadPackage(${DCMTK_MD5} ${DCMTK_URL} "${DCMTK_SOURCES_DIR}")
44
45 if (FirstRun)
46 message("Patching file")
47 execute_process(
48 COMMAND ${PATCH_EXECUTABLE} -p0 -N -i
49 ${CMAKE_SOURCE_DIR}/arith.patch
50 WORKING_DIRECTORY ${DCMTK_SOURCES_DIR}/config/tests
51 RESULT_VARIABLE Failure
52 )
53
54 if (Failure)
55 message(FATAL_ERROR "Error while patching a file")
56 endif()
57 endif()
58
59
60 #####################################################################
61 ## Build the DCMTK tests for arithmetics
62 #####################################################################
63
64 # https://github.com/kripken/emscripten/wiki/WebAssembly#web-server-setup
65 file(WRITE ${CMAKE_BINARY_DIR}/.htaccess "
66 AddType application/wasm .wasm
67 AddOutputFilterByType DEFLATE application/wasm
68 ")
69
70 file(WRITE ${CMAKE_BINARY_DIR}/dcmtk/config/osconfig.h "
71 #pragma once
72 #define HAVE_CMATH 1
73 #define HAVE_MATH_H 1
74 #define HAVE_PROTOTYPE_FINITE 1
75 #define HAVE_PROTOTYPE_STD__ISINF 1
76 #define HAVE_PROTOTYPE_STD__ISNAN 1
77 #define HAVE_STD_NAMESPACE 1
78 #define HAVE_STRSTREAM 1
79 #define SIZEOF_VOID_P 4
80 #define USE_STD_CXX_INCLUDES
81 ")
82
83 include_directories(
84 ${DCMTK_SOURCES_DIR}/ofstd/include
85 ${CMAKE_BINARY_DIR}
86 )
87
88 add_executable(dcmtk
89 ${DCMTK_SOURCES_DIR}/config/tests/arith.cc
90 ${CMAKE_SOURCE_DIR}/Run2.cpp
91 )
92
93 install(TARGETS dcmtk DESTINATION .)
94
95 install(FILES
96 ${CMAKE_BINARY_DIR}/.htaccess
97 ${CMAKE_BINARY_DIR}/dcmtk.wasm
98 ${CMAKE_SOURCE_DIR}/app.js
99 ${CMAKE_SOURCE_DIR}/index.html
100 DESTINATION .
101 )