Mercurial > hg > orthanc-stone
comparison Applications/Samples/Deprecated/CMakeLists.txt @ 1348:eac254fb6791 broker
Moved Application/Samples/* to Application/Samples/Deprecated/* (remaining) + moved Samples/* to Samples/Deprecated/*
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Tue, 07 Apr 2020 14:31:28 +0200 |
parents | Applications/Samples/CMakeLists.txt@ddb6676bbcbf |
children | c53a4667f895 |
comparison
equal
deleted
inserted
replaced
1347:bfd77672d825 | 1348:eac254fb6791 |
---|---|
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 set(ENABLE_STONE_DEPRECATED ON) # Need deprecated classes for these samples | |
12 set(EMSCRIPTEN_SET_LLVM_WASM_BACKEND ON) | |
13 | |
14 include(${ORTHANC_ROOT}/Resources/CMake/DownloadPackage.cmake) | |
15 DownloadPackage( | |
16 "a24b8136b8f3bb93f166baf97d9328de" | |
17 "http://orthanc.osimis.io/ThirdPartyDownloads/ubuntu-font-family-0.83.zip" | |
18 "${CMAKE_BINARY_DIR}/ubuntu-font-family-0.83") | |
19 | |
20 set(ORTHANC_STONE_APPLICATION_RESOURCES | |
21 UBUNTU_FONT ${CMAKE_BINARY_DIR}/ubuntu-font-family-0.83/Ubuntu-R.ttf | |
22 ) | |
23 | |
24 if (OPENSSL_NO_CAPIENG) | |
25 add_definitions(-DOPENSSL_NO_CAPIENG=1) | |
26 endif() | |
27 | |
28 | |
29 # the following block has been borrowed from orthanc/**/Compiler.cmake | |
30 if (MSVC_MULTIPLE_PROCESSES) | |
31 # "If you omit the processMax argument in the /MP option, the | |
32 # compiler obtains the number of effective processors from the | |
33 # operating system, and then creates one process per effective | |
34 # processor" | |
35 # https://blog.kitware.com/cmake-building-with-all-your-cores/ | |
36 # https://docs.microsoft.com/en-us/cpp/build/reference/mp-build-with-multiple-processes | |
37 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP") | |
38 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") | |
39 endif() | |
40 | |
41 #set(ENABLE_DCMTK ON) | |
42 | |
43 set(ENABLE_SDL OFF CACHE BOOL "Target SDL Native application") | |
44 set(ENABLE_QT OFF CACHE BOOL "Target Qt Native application") | |
45 set(ENABLE_WASM OFF CACHE BOOL "Target WASM application") | |
46 | |
47 if (ENABLE_WASM) | |
48 ##################################################################### | |
49 ## Configuration of the Emscripten compiler for WebAssembly target | |
50 ##################################################################### | |
51 | |
52 set(WASM_FLAGS "-s WASM=1") | |
53 set(WASM_FLAGS "${WASM_FLAGS} -s STRICT=1") # drops support for all deprecated build options | |
54 set(WASM_FLAGS "${WASM_FLAGS} -s FILESYSTEM=1") # if we don't include it, gen_uuid.c fails to build because srand, getpid(), ... are not defined | |
55 set(WASM_FLAGS "${WASM_FLAGS} -s DISABLE_EXCEPTION_CATCHING=0") # actually enable exception catching | |
56 set(WASM_FLAGS "${WASM_FLAGS} -s ERROR_ON_MISSING_LIBRARIES=1") | |
57 | |
58 if (CMAKE_BUILD_TYPE MATCHES DEBUG) | |
59 set(WASM_FLAGS "${WASM_FLAGS} -g4") # generate debug information | |
60 set(WASM_FLAGS "${WASM_FLAGS} -s ASSERTIONS=2") # more runtime checks | |
61 else() | |
62 set(WASM_FLAGS "${WASM_FLAGS} -Os") # optimize for web (speed and size) | |
63 endif() | |
64 | |
65 set(WASM_MODULE_NAME "StoneFrameworkModule" CACHE STRING "Name of the WebAssembly module") | |
66 | |
67 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WASM_FLAGS}") | |
68 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WASM_FLAGS}") | |
69 | |
70 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${WASM_FLAGS}") # not always clear which flags are for the compiler and which one are for the linker -> pass them all to the linker too | |
71 # set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --js-library ${STONE_SOURCES_DIR}/Applications/Samples/samples-library.js") | |
72 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --js-library ${STONE_SOURCES_DIR}/Platforms/Wasm/WasmWebService.js") | |
73 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --js-library ${STONE_SOURCES_DIR}/Platforms/Wasm/WasmDelayedCallExecutor.js") | |
74 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --js-library ${STONE_SOURCES_DIR}/Platforms/Wasm/default-library.js") | |
75 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s EXTRA_EXPORTED_RUNTIME_METHODS='[\"ccall\", \"cwrap\"]'") | |
76 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s EXPORT_NAME='\"${WASM_MODULE_NAME}\"'") | |
77 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s ALLOW_MEMORY_GROWTH=1") | |
78 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s TOTAL_MEMORY=536870912") | |
79 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s TOTAL_STACK=128000000") | |
80 | |
81 add_definitions(-DORTHANC_ENABLE_WASM=1) | |
82 set(ORTHANC_SANDBOXED ON) | |
83 | |
84 elseif (ENABLE_QT OR ENABLE_SDL) | |
85 | |
86 set(ENABLE_NATIVE ON) | |
87 set(ORTHANC_SANDBOXED OFF) | |
88 set(ENABLE_CRYPTO_OPTIONS ON) | |
89 set(ENABLE_GOOGLE_TEST ON) | |
90 set(ENABLE_WEB_CLIENT ON) | |
91 | |
92 else() | |
93 set(ENABLE_NATIVE ON) | |
94 set(ENABLE_OPENGL OFF) | |
95 | |
96 endif() | |
97 | |
98 | |
99 ##################################################################### | |
100 ## Configuration for Orthanc | |
101 ##################################################################### | |
102 | |
103 # include(../../Resources/CMake/Version.cmake) | |
104 | |
105 if (ORTHANC_STONE_VERSION STREQUAL "mainline") | |
106 set(ORTHANC_FRAMEWORK_VERSION "mainline") | |
107 set(ORTHANC_FRAMEWORK_DEFAULT_SOURCE "hg") | |
108 else() | |
109 set(ORTHANC_FRAMEWORK_VERSION "1.4.1") | |
110 set(ORTHANC_FRAMEWORK_DEFAULT_SOURCE "web") | |
111 endif() | |
112 | |
113 set(ORTHANC_FRAMEWORK_SOURCE "${ORTHANC_FRAMEWORK_DEFAULT_SOURCE}" CACHE STRING "Source of the Orthanc source code (can be \"hg\", \"archive\", \"web\" or \"path\")") | |
114 set(ORTHANC_FRAMEWORK_ARCHIVE "" CACHE STRING "Path to the Orthanc archive, if ORTHANC_FRAMEWORK_SOURCE is \"archive\"") | |
115 set(ORTHANC_FRAMEWORK_ROOT "" CACHE STRING "Path to the Orthanc source directory, if ORTHANC_FRAMEWORK_SOURCE is \"path\"") | |
116 | |
117 add_definitions( | |
118 -DORTHANC_ENABLE_LOGGING_PLUGIN=0 | |
119 ) | |
120 | |
121 | |
122 ##################################################################### | |
123 ## Build a static library containing the Orthanc Stone framework | |
124 ##################################################################### | |
125 | |
126 | |
127 LIST(APPEND ORTHANC_BOOST_COMPONENTS program_options) | |
128 | |
129 include(../../Resources/CMake/OrthancStoneConfiguration.cmake) | |
130 | |
131 add_library(OrthancStone STATIC | |
132 ${ORTHANC_STONE_SOURCES} | |
133 ) | |
134 | |
135 ##################################################################### | |
136 ## Build all the sample applications | |
137 ##################################################################### | |
138 | |
139 include_directories(${ORTHANC_STONE_ROOT}) | |
140 | |
141 # files common to all samples | |
142 list(APPEND SAMPLE_APPLICATIONS_SOURCES | |
143 ${ORTHANC_STONE_ROOT}/Applications/Samples/SampleInteractor.h | |
144 ${ORTHANC_STONE_ROOT}/Applications/Samples/SampleApplicationBase.h | |
145 ) | |
146 | |
147 if (ENABLE_QT) | |
148 list(APPEND SAMPLE_APPLICATIONS_SOURCES | |
149 ${ORTHANC_STONE_ROOT}/Applications/Samples/Qt/SampleQtApplicationRunner.h | |
150 ${ORTHANC_STONE_ROOT}/Applications/Samples/Qt/SampleMainWindow.cpp | |
151 ${ORTHANC_STONE_ROOT}/Applications/Samples/Qt/SampleMainWindowWithButtons.cpp | |
152 ) | |
153 | |
154 ORTHANC_QT_WRAP_UI(SAMPLE_APPLICATIONS_SOURCES | |
155 ${ORTHANC_STONE_ROOT}/Applications/Samples/Qt/SampleMainWindow.ui | |
156 ${ORTHANC_STONE_ROOT}/Applications/Samples/Qt/SampleMainWindowWithButtons.ui | |
157 ) | |
158 | |
159 ORTHANC_QT_WRAP_CPP(SAMPLE_APPLICATIONS_SOURCES | |
160 ${ORTHANC_STONE_ROOT}/Applications/Qt/QCairoWidget.h | |
161 ${ORTHANC_STONE_ROOT}/Applications/Qt/QStoneMainWindow.h | |
162 ${ORTHANC_STONE_ROOT}/Applications/Samples/Qt/SampleMainWindow.h | |
163 ${ORTHANC_STONE_ROOT}/Applications/Samples/Qt/SampleMainWindowWithButtons.h | |
164 ) | |
165 endif() | |
166 | |
167 if (ENABLE_NATIVE) | |
168 list(APPEND SAMPLE_APPLICATIONS_SOURCES | |
169 ${ORTHANC_STONE_ROOT}/Applications/Samples/SampleMainNative.cpp | |
170 ) | |
171 | |
172 elseif (ENABLE_WASM) | |
173 | |
174 list(APPEND SAMPLE_APPLICATIONS_SOURCES | |
175 ${ORTHANC_STONE_ROOT}/Applications/Samples/SampleMainWasm.cpp | |
176 ${STONE_WASM_SOURCES} | |
177 ) | |
178 endif() | |
179 | |
180 | |
181 macro(BuildSingleFileSample Target Header Sample) | |
182 add_executable(${Target} | |
183 ${ORTHANC_STONE_ROOT}/Applications/Samples/${Header} | |
184 ${SAMPLE_APPLICATIONS_SOURCES} | |
185 ) | |
186 set_target_properties(${Target} PROPERTIES COMPILE_DEFINITIONS ORTHANC_STONE_SAMPLE=${Sample}) | |
187 target_link_libraries(${Target} OrthancStone) | |
188 endmacro() | |
189 | |
190 | |
191 if (ENABLE_SDL) | |
192 #BuildSingleFileSample(OrthancStoneEmpty EmptyApplication.h 1) | |
193 #BuildSingleFileSample(OrthancStoneTestPattern TestPatternApplication.h 2) | |
194 BuildSingleFileSample(OrthancStoneSingleFrame SingleFrameApplication.h 3) | |
195 #BuildSingleFileSample(OrthancStoneSingleVolume SingleVolumeApplication.h 4) | |
196 #BuildSingleFileSample(OrthancStoneBasicPetCtFusion 5) | |
197 #BuildSingleFileSample(OrthancStoneSynchronizedSeries 6) | |
198 #BuildSingleFileSample(OrthancStoneLayoutPetCtFusion 7) | |
199 BuildSingleFileSample(OrthancStoneSimpleViewerSingleFile SimpleViewerApplicationSingleFile.h 8) # we keep that one just as a sample before we convert another sample to this pattern | |
200 BuildSingleFileSample(OrthancStoneSingleFrameEditor SingleFrameEditorApplication.h 9) | |
201 endif() | |
202 | |
203 ##### SimpleViewer sample (Qt and WASM only) ####### | |
204 | |
205 if (ENABLE_QT OR ENABLE_WASM) | |
206 | |
207 if (ENABLE_QT) | |
208 list(APPEND SIMPLE_VIEWER_APPLICATION_SOURCES | |
209 ${ORTHANC_STONE_ROOT}/Applications/Samples/SimpleViewer/Qt/SimpleViewerMainWindow.cpp | |
210 ${ORTHANC_STONE_ROOT}/Applications/Samples/SimpleViewer/Qt/SimpleViewerMainWindow.ui | |
211 ${ORTHANC_STONE_ROOT}/Applications/Samples/SimpleViewer/Qt/mainQt.cpp | |
212 ) | |
213 | |
214 ORTHANC_QT_WRAP_UI(SIMPLE_VIEWER_APPLICATION_SOURCES | |
215 ${ORTHANC_STONE_ROOT}/Applications/Samples/SimpleViewer/Qt/SimpleViewerMainWindow.ui | |
216 ) | |
217 | |
218 ORTHANC_QT_WRAP_CPP(SIMPLE_VIEWER_APPLICATION_SOURCES | |
219 ${ORTHANC_STONE_ROOT}/Applications/Samples/SimpleViewer/Qt/SimpleViewerMainWindow.h | |
220 ) | |
221 | |
222 elseif (ENABLE_WASM) | |
223 list(APPEND SIMPLE_VIEWER_APPLICATION_SOURCES | |
224 ${ORTHANC_STONE_ROOT}/Applications/Samples/SimpleViewer/Wasm/mainWasm.cpp | |
225 ${ORTHANC_STONE_ROOT}/Applications/Samples/SimpleViewer/Wasm/SimpleViewerWasmApplicationAdapter.cpp | |
226 ${ORTHANC_STONE_ROOT}/Applications/Samples/SimpleViewer/Wasm/SimpleViewerWasmApplicationAdapter.h | |
227 ${STONE_WASM_SOURCES} | |
228 ) | |
229 endif() | |
230 | |
231 add_executable(OrthancStoneSimpleViewer | |
232 ${ORTHANC_STONE_ROOT}/Applications/Samples/SimpleViewer/AppStatus.h | |
233 ${ORTHANC_STONE_ROOT}/Applications/Samples/SimpleViewer/MainWidgetInteractor.cpp | |
234 ${ORTHANC_STONE_ROOT}/Applications/Samples/SimpleViewer/MainWidgetInteractor.h | |
235 ${ORTHANC_STONE_ROOT}/Applications/Samples/SimpleViewer/SimpleViewerApplication.cpp | |
236 ${ORTHANC_STONE_ROOT}/Applications/Samples/SimpleViewer/SimpleViewerApplication.h | |
237 ${ORTHANC_STONE_ROOT}/Applications/Samples/SimpleViewer/ThumbnailInteractor.cpp | |
238 ${ORTHANC_STONE_ROOT}/Applications/Samples/SimpleViewer/ThumbnailInteractor.h | |
239 ${SIMPLE_VIEWER_APPLICATION_SOURCES} | |
240 ) | |
241 target_link_libraries(OrthancStoneSimpleViewer OrthancStone) | |
242 | |
243 BuildSingleFileSample(OrthancStoneSingleFrameEditor SingleFrameEditorApplication.h 9) | |
244 endif() | |
245 | |
246 ##################################################################### | |
247 ## Build the unit tests | |
248 ##################################################################### | |
249 | |
250 if (ENABLE_NATIVE) | |
251 add_executable(UnitTests | |
252 ${GOOGLE_TEST_SOURCES} | |
253 ${ORTHANC_STONE_ROOT}/UnitTestsSources/GenericToolboxTests.cpp | |
254 ${ORTHANC_STONE_ROOT}/UnitTestsSources/ImageToolboxTests.cpp | |
255 ${ORTHANC_STONE_ROOT}/UnitTestsSources/PixelTestPatternsTests.cpp | |
256 ${ORTHANC_STONE_ROOT}/UnitTestsSources/TestCommands.cpp | |
257 ${ORTHANC_STONE_ROOT}/UnitTestsSources/TestMessageBroker.cpp | |
258 ${ORTHANC_STONE_ROOT}/UnitTestsSources/TestStrategy.cpp | |
259 ${ORTHANC_STONE_ROOT}/UnitTestsSources/TestStructureSet.cpp | |
260 ${ORTHANC_STONE_ROOT}/UnitTestsSources/UnitTestsMain.cpp | |
261 ) | |
262 | |
263 target_link_libraries(UnitTests OrthancStone) | |
264 | |
265 add_custom_command( | |
266 TARGET UnitTests | |
267 POST_BUILD | |
268 COMMAND ${CMAKE_COMMAND} -E copy | |
269 "${ORTHANC_STONE_ROOT}/UnitTestsSources/72c773ac-5059f2c4-2e6a9120-4fd4bca1-45701661.json" | |
270 "$<TARGET_FILE_DIR:UnitTests>/72c773ac-5059f2c4-2e6a9120-4fd4bca1-45701661.json" | |
271 ) | |
272 | |
273 endif() | |
274 | |
275 ##################################################################### | |
276 ## Generate the documentation if Doxygen is present | |
277 ##################################################################### | |
278 | |
279 find_package(Doxygen) | |
280 if (DOXYGEN_FOUND) | |
281 configure_file( | |
282 ${ORTHANC_STONE_ROOT}/Resources/OrthancStone.doxygen | |
283 ${CMAKE_CURRENT_BINARY_DIR}/OrthancStone.doxygen | |
284 @ONLY) | |
285 | |
286 add_custom_target(doc | |
287 ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/OrthancStone.doxygen | |
288 COMMENT "Generating documentation with Doxygen" VERBATIM | |
289 ) | |
290 else() | |
291 message("Doxygen not found. The documentation will not be built.") | |
292 endif() |