Mercurial > hg > orthanc-stone
comparison Samples/WebAssembly/CMakeLists.txt @ 616:97926984d5d0
WebAssembly sample using Scene2D
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 02 May 2019 13:27:41 +0200 |
parents | |
children | ea8322566596 |
comparison
equal
deleted
inserted
replaced
615:b4de8272e8fb | 616:97926984d5d0 |
---|---|
1 | |
2 # source ~/Downloads/emsdk/emsdk_env.sh | |
3 # cmake -G Ninja -DCMAKE_TOOLCHAIN_FILE=${EMSCRIPTEN}/cmake/Modules/Platform/Emscripten.cmake -DCMAKE_BUILD_TYPE=Release -DALLOW_DOWNLOADS=ON .. -DCMAKE_INSTALL_PREFIX=/tmp/stone | |
4 # ninja install | |
5 # sudo docker run -p 4242:4242 -p 8042:8042 --rm -v /tmp/stone:/root/stone:ro jodogne/orthanc-plugins:1.5.6 /root/stone/Configuration.json --verbose | |
6 | |
7 | |
8 cmake_minimum_required(VERSION 2.8.3) | |
9 | |
10 | |
11 ##################################################################### | |
12 ## Configuration of the Emscripten compiler for WebAssembly target | |
13 ##################################################################### | |
14 | |
15 set(WASM_FLAGS "-s WASM=1 -s FETCH=1") | |
16 | |
17 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WASM_FLAGS}") | |
18 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WASM_FLAGS}") | |
19 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s EXTRA_EXPORTED_RUNTIME_METHODS='[\"ccall\", \"cwrap\"]'") | |
20 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s ERROR_ON_UNDEFINED_SYMBOLS=1") | |
21 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s ALLOW_MEMORY_GROWTH=1") | |
22 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s ASSERTIONS=1 -s DISABLE_EXCEPTION_CATCHING=0") | |
23 | |
24 | |
25 ##################################################################### | |
26 ## Configuration of the Orthanc framework | |
27 ##################################################################### | |
28 | |
29 # This CMake file defines the "ORTHANC_STONE_VERSION" macro, so it | |
30 # must be the first inclusion | |
31 include(${CMAKE_SOURCE_DIR}/../../Resources/CMake/Version.cmake) | |
32 | |
33 if (ORTHANC_STONE_VERSION STREQUAL "mainline") | |
34 set(ORTHANC_FRAMEWORK_VERSION "mainline") | |
35 set(ORTHANC_FRAMEWORK_DEFAULT_SOURCE "hg") | |
36 else() | |
37 set(ORTHANC_FRAMEWORK_VERSION "1.5.7") | |
38 set(ORTHANC_FRAMEWORK_DEFAULT_SOURCE "web") | |
39 endif() | |
40 | |
41 set(ORTHANC_FRAMEWORK_SOURCE "${ORTHANC_FRAMEWORK_DEFAULT_SOURCE}" CACHE STRING "Source of the Orthanc source code (can be \"hg\", \"archive\", \"web\" or \"path\")") | |
42 set(ORTHANC_FRAMEWORK_ARCHIVE "" CACHE STRING "Path to the Orthanc archive, if ORTHANC_FRAMEWORK_SOURCE is \"archive\"") | |
43 set(ORTHANC_FRAMEWORK_ROOT "" CACHE STRING "Path to the Orthanc source directory, if ORTHANC_FRAMEWORK_SOURCE is \"path\"") | |
44 | |
45 | |
46 ##################################################################### | |
47 ## Configuration of the Stone framework | |
48 ##################################################################### | |
49 | |
50 include(${CMAKE_SOURCE_DIR}/../../Resources/CMake/OrthancStoneParameters.cmake) | |
51 include(${ORTHANC_ROOT}/Resources/CMake/DownloadPackage.cmake) | |
52 | |
53 DownloadPackage( | |
54 "a24b8136b8f3bb93f166baf97d9328de" | |
55 "http://orthanc.osimis.io/ThirdPartyDownloads/ubuntu-font-family-0.83.zip" | |
56 "${CMAKE_BINARY_DIR}/ubuntu-font-family-0.83") | |
57 | |
58 set(ORTHANC_STONE_APPLICATION_RESOURCES | |
59 UBUNTU_FONT ${CMAKE_BINARY_DIR}/ubuntu-font-family-0.83/Ubuntu-R.ttf | |
60 ) | |
61 | |
62 SET(ENABLE_GOOGLE_TEST OFF) | |
63 SET(ENABLE_LOCALE ON) | |
64 SET(ORTHANC_SANDBOXED ON) | |
65 SET(ENABLE_WASM ON) | |
66 | |
67 include(${CMAKE_SOURCE_DIR}/../../Resources/CMake/OrthancStoneConfiguration.cmake) | |
68 | |
69 | |
70 ##################################################################### | |
71 ## Build the samples | |
72 ##################################################################### | |
73 | |
74 add_library(OrthancStone STATIC | |
75 ${ORTHANC_STONE_SOURCES} | |
76 ) | |
77 | |
78 add_executable(BasicScene | |
79 BasicScene.cpp | |
80 ) | |
81 | |
82 target_link_libraries(BasicScene OrthancStone) | |
83 | |
84 install( | |
85 TARGETS BasicScene | |
86 RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX} | |
87 ) | |
88 | |
89 install( | |
90 FILES | |
91 ${CMAKE_CURRENT_BINARY_DIR}/BasicScene.wasm | |
92 ${CMAKE_SOURCE_DIR}/BasicScene.html | |
93 ${CMAKE_SOURCE_DIR}/Configuration.json | |
94 ${CMAKE_SOURCE_DIR}/index.html | |
95 DESTINATION ${CMAKE_INSTALL_PREFIX} | |
96 ) |