comparison Applications/Samples/CMakeLists.txt.old @ 518:40bb5eb247a5 bgo-commands-codegen

Reverted a couple of files to AM version (wrong changes on my end)
author Benjamin Golinvaux <bgo@osimis.io>
date Tue, 12 Mar 2019 09:19:06 +0100
parents
children
comparison
equal deleted inserted replaced
517:64ee3033e1ca 518:40bb5eb247a5
1 # Usage: see README file
2
3 cmake_minimum_required(VERSION 2.8.3)
4
5 # Automatically link Qt executables to qtmain target on Windows
6 # ("OLD" == do not link)
7 if(POLICY CMP0020)
8 cmake_policy(SET CMP0020 OLD)
9 endif()
10
11 # Only interpret if() arguments as variables or keywords when unquoted.
12 # NEW = do NOT dereference *quoted* variables
13 if(POLICY CMP0054)
14 cmake_policy(SET CMP0054 NEW)
15 endif()
16
17 project(OrthancStone)
18
19 include(../../Resources/CMake/OrthancStoneParameters.cmake)
20
21 #set(ENABLE_DCMTK ON)
22
23 set(ENABLE_SDL OFF CACHE BOOL "Target SDL Native application")
24 set(ENABLE_QT OFF CACHE BOOL "Target Qt Native application")
25 set(ENABLE_WASM OFF CACHE BOOL "Target WASM application")
26
27 # TODO: replace or compute STONE_SOURCES_DIR from CMAKE_CURRENT_LIST_FILE
28
29 if (ENABLE_WASM)
30 #####################################################################
31 ## Configuration of the Emscripten compiler for WebAssembly target
32 #####################################################################
33
34 set(WASM_FLAGS "-s WASM=1 -O0 -g0")
35 message("*****************************************************************************")
36 message("WARNING: optimizations are disabled in emcc!!! Enable them for production use")
37 message("*****************************************************************************")
38 set(WASM_MODULE_NAME "StoneFrameworkModule" CACHE STRING "Name of the WebAssembly module")
39 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WASM_FLAGS}")
40 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WASM_FLAGS}")
41 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --js-library ${STONE_SOURCES_DIR}/Platforms/Wasm/WasmWebService.js --js-library ${STONE_SOURCES_DIR}/Platforms/Wasm/WasmDelayedCallExecutor.js --js-library ${STONE_SOURCES_DIR}/Platforms/Wasm/default-library.js -s EXTRA_EXPORTED_RUNTIME_METHODS='[\"ccall\", \"cwrap\"]'")
42
43 # Handling of memory
44 #set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s ALLOW_MEMORY_GROWTH=1") # Resize
45 #set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s TOTAL_MEMORY=536870912") # 512MB
46 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
47 #set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s ALLOW_MEMORY_GROWTH=1 -s TOTAL_MEMORY=1073741824") # 1GB + resize
48
49 # To debug exceptions
50 #set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s DEMANGLE_SUPPORT=1 -s ASSERTIONS=2")
51
52 add_definitions(-DORTHANC_ENABLE_WASM=1)
53 set(ORTHANC_SANDBOXED ON)
54
55 elseif (ENABLE_QT OR ENABLE_SDL)
56
57 set(ENABLE_NATIVE ON)
58 set(ORTHANC_SANDBOXED OFF)
59 set(ENABLE_CRYPTO_OPTIONS ON)
60 set(ENABLE_GOOGLE_TEST ON)
61 set(ENABLE_WEB_CLIENT ON)
62
63 endif()
64
65 #####################################################################
66 ## Configuration for Orthanc
67 #####################################################################
68
69 # include(../../Resources/CMake/Version.cmake)
70
71 if (ORTHANC_STONE_VERSION STREQUAL "mainline")
72 set(ORTHANC_FRAMEWORK_VERSION "mainline")
73 set(ORTHANC_FRAMEWORK_DEFAULT_SOURCE "hg")
74 else()
75 set(ORTHANC_FRAMEWORK_VERSION "1.4.1")
76 set(ORTHANC_FRAMEWORK_DEFAULT_SOURCE "web")
77 endif()
78
79 set(ORTHANC_FRAMEWORK_SOURCE "${ORTHANC_FRAMEWORK_DEFAULT_SOURCE}" CACHE STRING "Source of the Orthanc source code (can be \"hg\", \"archive\", \"web\" or \"path\")")
80 set(ORTHANC_FRAMEWORK_ARCHIVE "" CACHE STRING "Path to the Orthanc archive, if ORTHANC_FRAMEWORK_SOURCE is \"archive\"")
81 set(ORTHANC_FRAMEWORK_ROOT "" CACHE STRING "Path to the Orthanc source directory, if ORTHANC_FRAMEWORK_SOURCE is \"path\"")
82
83 #####################################################################
84 ## Build a static library containing the Orthanc Stone framework
85 #####################################################################
86
87 LIST(APPEND ORTHANC_BOOST_COMPONENTS program_options)
88
89 include(../../Resources/CMake/OrthancStoneConfiguration.cmake)
90
91 add_library(OrthancStone STATIC
92 ${ORTHANC_STONE_SOURCES}
93 )
94
95 #####################################################################
96 ## Build all the sample applications
97 #####################################################################
98
99 include_directories(${ORTHANC_STONE_ROOT})
100
101 # files common to all samples
102 list(APPEND SAMPLE_APPLICATIONS_SOURCES
103 ${ORTHANC_STONE_ROOT}/Applications/Samples/SampleInteractor.h
104 ${ORTHANC_STONE_ROOT}/Applications/Samples/SampleApplicationBase.h
105 )
106
107 if (ENABLE_QT)
108 list(APPEND SAMPLE_APPLICATIONS_SOURCES
109 ${ORTHANC_STONE_ROOT}/Applications/Samples/Qt/SampleQtApplicationRunner.h
110 ${ORTHANC_STONE_ROOT}/Applications/Samples/Qt/SampleMainWindow.cpp
111 ${ORTHANC_STONE_ROOT}/Applications/Samples/Qt/SampleMainWindowWithButtons.cpp
112 )
113
114 ORTHANC_QT_WRAP_UI(SAMPLE_APPLICATIONS_SOURCES
115 ${ORTHANC_STONE_ROOT}/Applications/Samples/Qt/SampleMainWindow.ui
116 ${ORTHANC_STONE_ROOT}/Applications/Samples/Qt/SampleMainWindowWithButtons.ui
117 )
118
119 ORTHANC_QT_WRAP_CPP(SAMPLE_APPLICATIONS_SOURCES
120 ${ORTHANC_STONE_ROOT}/Applications/Qt/QCairoWidget.h
121 ${ORTHANC_STONE_ROOT}/Applications/Qt/QStoneMainWindow.h
122 ${ORTHANC_STONE_ROOT}/Applications/Samples/Qt/SampleMainWindow.h
123 ${ORTHANC_STONE_ROOT}/Applications/Samples/Qt/SampleMainWindowWithButtons.h
124 )
125 endif()
126
127 if (ENABLE_NATIVE)
128 list(APPEND SAMPLE_APPLICATIONS_SOURCES
129 ${ORTHANC_STONE_ROOT}/Applications/Samples/SampleMainNative.cpp
130 )
131
132 elseif (ENABLE_WASM)
133
134 list(APPEND SAMPLE_APPLICATIONS_SOURCES
135 ${ORTHANC_STONE_ROOT}/Applications/Samples/SampleMainWasm.cpp
136 ${STONE_WASM_SOURCES}
137 )
138 endif()
139
140
141 macro(BuildSingleFileSample Target Header Sample)
142 add_executable(${Target}
143 ${ORTHANC_STONE_ROOT}/Applications/Samples/${Header}
144 ${SAMPLE_APPLICATIONS_SOURCES}
145 )
146 set_target_properties(${Target} PROPERTIES COMPILE_DEFINITIONS ORTHANC_STONE_SAMPLE=${Sample})
147 target_link_libraries(${Target} OrthancStone)
148
149 if (ENABLE_QT AND (CMAKE_SYSTEM_NAME STREQUAL "Windows"))
150 message("(ENABLE_QT and (CMAKE_SYSTEM_NAME matches \"Windows\")) is true")
151 add_custom_command(
152 TARGET ${Target} POST_BUILD
153 COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:Qt5::Core> $<TARGET_FILE_DIR:${Target}>
154 COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:Qt5::Widgets> $<TARGET_FILE_DIR:${Target}>
155 COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:Qt5::Gui> $<TARGET_FILE_DIR:${Target}>
156 )
157 endif()
158 endmacro()
159
160 #BuildSingleFileSample(OrthancStoneEmpty EmptyApplication.h 1)
161 #BuildSingleFileSample(OrthancStoneTestPattern TestPatternApplication.h 2)
162 BuildSingleFileSample(OrthancStoneSingleFrame SingleFrameApplication.h 3)
163 #BuildSingleFileSample(OrthancStoneSingleVolume SingleVolumeApplication.h 4)
164 #BuildSingleFileSample(OrthancStoneBasicPetCtFusion 5)
165 #BuildSingleFileSample(OrthancStoneSynchronizedSeries 6)
166 #BuildSingleFileSample(OrthancStoneLayoutPetCtFusion 7)
167 BuildSingleFileSample(OrthancStoneSimpleViewerSingleFile SimpleViewerApplicationSingleFile.h 8) # we keep that one just as a sample before we convert another sample to this pattern
168 BuildSingleFileSample(OrthancStoneSingleFrameEditor SingleFrameEditorApplication.h 9)
169
170 ##### SimpleViewer sample (Qt and WASM only) #######
171
172 if (ENABLE_QT OR ENABLE_WASM)
173
174 # GenerateCodeFromFlatBufferSchema("${ORTHANC_STONE_ROOT}/Applications/Samples/SimpleViewer/ApplicationCommands.fbs")
175
176 list(APPEND SIMPLE_VIEWER_APPLICATION_SOURCES ${FLATC_AUTOGENERATED_SOURCES})
177 message(STATUS "SIMPLE_VIEWER_APPLICATION_SOURCES = ${SIMPLE_VIEWER_APPLICATION_SOURCES}")
178 message(STATUS "FLATC_AUTOGENERATED_SOURCES = ${FLATC_AUTOGENERATED_SOURCES}")
179
180 if (ENABLE_QT)
181 list(APPEND SIMPLE_VIEWER_APPLICATION_SOURCES
182 ${ORTHANC_STONE_ROOT}/Applications/Samples/SimpleViewer/Qt/SimpleViewerMainWindow.cpp
183 ${ORTHANC_STONE_ROOT}/Applications/Samples/SimpleViewer/Qt/SimpleViewerMainWindow.ui
184 ${ORTHANC_STONE_ROOT}/Applications/Samples/SimpleViewer/Qt/mainQt.cpp
185 )
186
187 ORTHANC_QT_WRAP_UI(SIMPLE_VIEWER_APPLICATION_SOURCES
188 ${ORTHANC_STONE_ROOT}/Applications/Samples/SimpleViewer/Qt/SimpleViewerMainWindow.ui
189 )
190
191 ORTHANC_QT_WRAP_CPP(SIMPLE_VIEWER_APPLICATION_SOURCES
192 ${ORTHANC_STONE_ROOT}/Applications/Samples/SimpleViewer/Qt/SimpleViewerMainWindow.h
193 )
194
195 elseif (ENABLE_WASM)
196 list(APPEND SIMPLE_VIEWER_APPLICATION_SOURCES
197 ${ORTHANC_STONE_ROOT}/Applications/Samples/SimpleViewer/Wasm/mainWasm.cpp
198 ${ORTHANC_STONE_ROOT}/Applications/Samples/SimpleViewer/Wasm/SimpleViewerWasmApplicationAdapter.cpp
199 ${STONE_WASM_SOURCES}
200 )
201 endif()
202
203 add_executable(OrthancStoneSimpleViewer
204 ${ORTHANC_STONE_ROOT}/Applications/Samples/SimpleViewer/SimpleViewerApplication.cpp
205 ${ORTHANC_STONE_ROOT}/Applications/Samples/SimpleViewer/ThumbnailInteractor.cpp
206 ${ORTHANC_STONE_ROOT}/Applications/Samples/SimpleViewer/MainWidgetInteractor.cpp
207 ${ORTHANC_STONE_ROOT}/Applications/Samples/SimpleViewer/AppStatus.h
208 ${ORTHANC_STONE_ROOT}/Applications/Samples/SimpleViewer/Messages.h
209 ${SIMPLE_VIEWER_APPLICATION_SOURCES}
210 )
211 target_link_libraries(OrthancStoneSimpleViewer OrthancStone)
212
213 endif()
214
215 #####################################################################
216 ## Build the unit tests
217 #####################################################################
218
219 if (ENABLE_NATIVE)
220 add_executable(UnitTests
221 ${GOOGLE_TEST_SOURCES}
222 ${ORTHANC_STONE_ROOT}/UnitTestsSources/TestCommands.cpp
223 ${ORTHANC_STONE_ROOT}/UnitTestsSources/TestExceptions.cpp
224 ${ORTHANC_STONE_ROOT}/UnitTestsSources/TestMessageBroker.cpp
225 ${ORTHANC_STONE_ROOT}/UnitTestsSources/UnitTestsMain.cpp
226 )
227
228 target_link_libraries(UnitTests OrthancStone)
229 endif()
230
231 #####################################################################
232 ## Generate the documentation if Doxygen is present
233 #####################################################################
234
235 find_package(Doxygen)
236 if (DOXYGEN_FOUND)
237 configure_file(
238 ${ORTHANC_STONE_ROOT}/Resources/OrthancStone.doxygen
239 ${CMAKE_CURRENT_BINARY_DIR}/OrthancStone.doxygen
240 @ONLY)
241
242 add_custom_target(doc
243 ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/OrthancStone.doxygen
244 COMMENT "Generating documentation with Doxygen" VERBATIM
245 )
246 else()
247 message("Doxygen not found. The documentation will not be built.")
248 endif()