Mercurial > hg > orthanc-stone
comparison Applications/Samples/CMakeLists.txt @ 295:b04b13810540 am-2
unified CMakeLists.txt into a single file for WASM/Native + bootstrap Command (to rework) + doc
author | am@osimis.io |
---|---|
date | Tue, 04 Sep 2018 15:09:42 +0200 |
parents | |
children | f58bfb7bbcc9 |
comparison
equal
deleted
inserted
replaced
294:faccc4b07b92 | 295:b04b13810540 |
---|---|
1 # Usage (Linux): | |
2 # to build the WASM samples | |
3 # source ~/Downloads/emsdk/emsdk_env.sh && cmake -DCMAKE_TOOLCHAIN_FILE=${EMSCRIPTEN}/cmake/Modules/Platform/Emscripten.cmake -DCMAKE_BUILD_TYPE=Release -DSTONE_SOURCES_DIR=$currentDir/../../../orthanc-stone -DORTHANC_FRAMEWORK_SOURCE=path -DORTHANC_FRAMEWORK_ROOT=$currentDir/../../../orthanc -DALLOW_DOWNLOADS=ON .. -DENABLE_WASM=ON | |
4 # to build the Qt samples | |
5 | |
6 cmake_minimum_required(VERSION 2.8.3) | |
7 project(OrthancStone) | |
8 | |
9 include(../../Resources/CMake/OrthancStoneParameters.cmake) | |
10 | |
11 | |
12 set(ENABLE_SDL OFF CACHE BOOL "Target SDL Native application") | |
13 set(ENABLE_QT OFF CACHE BOOL "Target Qt Native application") | |
14 set(ENABLE_WASM OFF CACHE BOOL "Target WASM application") | |
15 | |
16 if (ENABLE_WASM) | |
17 ##################################################################### | |
18 ## Configuration of the Emscripten compiler for WebAssembly target | |
19 ##################################################################### | |
20 | |
21 set(WASM_FLAGS "-s WASM=1") | |
22 set(WASM_MODULE_NAME "StoneFrameworkModule" CACHE STRING "Name of the WebAssembly module") | |
23 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WASM_FLAGS}") | |
24 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WASM_FLAGS}") | |
25 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --js-library ${STONE_SOURCES_DIR}/Applications/Samples/samples-library.js --js-library ${STONE_SOURCES_DIR}/Platforms/Wasm/WasmWebService.js --js-library ${STONE_SOURCES_DIR}/Platforms/Wasm/default-library.js -s EXTRA_EXPORTED_RUNTIME_METHODS='[\"ccall\", \"cwrap\"]'") | |
26 | |
27 # Handling of memory | |
28 #set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s ALLOW_MEMORY_GROWTH=1") # Resize | |
29 #set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s TOTAL_MEMORY=536870912") # 512MB | |
30 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s EXPORT_NAME='\"${WASM_MODULE_NAME}\"' -s ALLOW_MEMORY_GROWTH=1 -s TOTAL_MEMORY=536870912 -s TOTAL_STACK=128000000") # 512MB + resize | |
31 #set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s ALLOW_MEMORY_GROWTH=1 -s TOTAL_MEMORY=1073741824") # 1GB + resize | |
32 | |
33 # To debug exceptions | |
34 #set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s DEMANGLE_SUPPORT=1 -s ASSERTIONS=2") | |
35 | |
36 add_definitions(-DORTHANC_ENABLE_WASM=1) | |
37 set(ORTHANC_SANDBOXED ON) | |
38 | |
39 elseif (ENABLE_QT OR ENABLE_SDL) | |
40 | |
41 set(ENABLE_NATIVE ON) | |
42 set(ORTHANC_SANDBOXED OFF) | |
43 set(ENABLE_CRYPTO_OPTIONS ON) | |
44 set(ENABLE_GOOGLE_TEST ON) | |
45 set(ENABLE_WEB_CLIENT ON) | |
46 | |
47 endif() | |
48 | |
49 ##################################################################### | |
50 ## Configuration for Orthanc | |
51 ##################################################################### | |
52 | |
53 # include(../../Resources/CMake/Version.cmake) | |
54 | |
55 if (ORTHANC_STONE_VERSION STREQUAL "mainline") | |
56 set(ORTHANC_FRAMEWORK_VERSION "mainline") | |
57 set(ORTHANC_FRAMEWORK_DEFAULT_SOURCE "hg") | |
58 else() | |
59 set(ORTHANC_FRAMEWORK_VERSION "1.4.1") | |
60 set(ORTHANC_FRAMEWORK_DEFAULT_SOURCE "web") | |
61 endif() | |
62 | |
63 set(ORTHANC_FRAMEWORK_SOURCE "${ORTHANC_FRAMEWORK_DEFAULT_SOURCE}" CACHE STRING "Source of the Orthanc source code (can be \"hg\", \"archive\", \"web\" or \"path\")") | |
64 set(ORTHANC_FRAMEWORK_ARCHIVE "" CACHE STRING "Path to the Orthanc archive, if ORTHANC_FRAMEWORK_SOURCE is \"archive\"") | |
65 set(ORTHANC_FRAMEWORK_ROOT "" CACHE STRING "Path to the Orthanc source directory, if ORTHANC_FRAMEWORK_SOURCE is \"path\"") | |
66 | |
67 | |
68 ##################################################################### | |
69 ## Build a static library containing the Orthanc Stone framework | |
70 ##################################################################### | |
71 | |
72 | |
73 LIST(APPEND ORTHANC_BOOST_COMPONENTS program_options) | |
74 | |
75 include(../../Resources/CMake/OrthancStoneConfiguration.cmake) | |
76 | |
77 add_library(OrthancStone STATIC | |
78 ${ORTHANC_STONE_SOURCES} | |
79 ) | |
80 | |
81 ##################################################################### | |
82 ## Build all the sample applications | |
83 ##################################################################### | |
84 | |
85 include_directories(${ORTHANC_STONE_ROOT}) | |
86 | |
87 # files common to all samples | |
88 list(APPEND APPLICATIONS_SOURCES | |
89 ${ORTHANC_STONE_ROOT}/Applications/Samples/SampleInteractor.h | |
90 ${ORTHANC_STONE_ROOT}/Applications/Samples/SampleApplicationBase.h | |
91 ) | |
92 | |
93 if (ENABLE_QT) | |
94 list(APPEND APPLICATIONS_SOURCES | |
95 ${ORTHANC_STONE_ROOT}/Applications/Samples/Qt/SampleQtApplicationRunner.h | |
96 ${ORTHANC_STONE_ROOT}/Applications/Samples/Qt/SampleMainWindow.cpp | |
97 ${ORTHANC_STONE_ROOT}/Applications/Samples/Qt/SampleMainWindow.ui | |
98 ) | |
99 endif() | |
100 | |
101 if (ENABLE_NATIVE) | |
102 list(APPEND APPLICATIONS_SOURCES | |
103 ${ORTHANC_STONE_ROOT}/Applications/Samples/SampleMainNative.cpp | |
104 ) | |
105 | |
106 elseif (ENABLE_WASM) | |
107 | |
108 list(APPEND APPLICATIONS_SOURCES | |
109 ${ORTHANC_STONE_ROOT}/Applications/Samples/SampleMainWasm.cpp | |
110 ${STONE_WASM_SOURCES} | |
111 ) | |
112 endif() | |
113 | |
114 | |
115 macro(BuildSingleFileSample Target Header Sample) | |
116 add_executable(${Target} | |
117 ${ORTHANC_STONE_ROOT}/Applications/Samples/${Header} | |
118 ${APPLICATIONS_SOURCES} | |
119 ) | |
120 set_target_properties(${Target} PROPERTIES COMPILE_DEFINITIONS ORTHANC_STONE_SAMPLE=${Sample}) | |
121 target_link_libraries(${Target} OrthancStone) | |
122 endmacro() | |
123 | |
124 #BuildSingleFileSample(OrthancStoneEmpty EmptyApplication.h 1) | |
125 #BuildSingleFileSample(OrthancStoneTestPattern TestPatternApplication.h 2) | |
126 #BuildSingleFileSample(OrthancStoneSingleFrame SingleFrameApplication.h 3) | |
127 #BuildSingleFileSample(OrthancStoneSingleVolume SingleVolumeApplication.h 4) | |
128 #BuildSingleFileSample(OrthancStoneBasicPetCtFusion 5) | |
129 #BuildSingleFileSample(OrthancStoneSynchronizedSeries 6) | |
130 #BuildSingleFileSample(OrthancStoneLayoutPetCtFusion 7) | |
131 BuildSingleFileSample(OrthancStoneSimpleViewer SimpleViewerApplication.h 8) | |
132 | |
133 ##################################################################### | |
134 ## Build the unit tests | |
135 ##################################################################### | |
136 | |
137 if (ENABLE_NATIVE) | |
138 add_executable(UnitTests | |
139 ${GOOGLE_TEST_SOURCES} | |
140 ${ORTHANC_STONE_ROOT}/UnitTestsSources/TestMessageBroker.cpp | |
141 ${ORTHANC_STONE_ROOT}/UnitTestsSources/TestCommands.cpp | |
142 ${ORTHANC_STONE_ROOT}/UnitTestsSources/UnitTestsMain.cpp | |
143 ) | |
144 | |
145 target_link_libraries(UnitTests OrthancStone) | |
146 endif() | |
147 | |
148 ##################################################################### | |
149 ## Generate the documentation if Doxygen is present | |
150 ##################################################################### | |
151 | |
152 find_package(Doxygen) | |
153 if (DOXYGEN_FOUND) | |
154 configure_file( | |
155 ${ORTHANC_STONE_ROOT}/Resources/OrthancStone.doxygen | |
156 ${CMAKE_CURRENT_BINARY_DIR}/OrthancStone.doxygen | |
157 @ONLY) | |
158 | |
159 add_custom_target(doc | |
160 ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/OrthancStone.doxygen | |
161 COMMENT "Generating documentation with Doxygen" VERBATIM | |
162 ) | |
163 else() | |
164 message("Doxygen not found. The documentation will not be built.") | |
165 endif() |