-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
457 lines (377 loc) · 16.4 KB
/
Copy pathCMakeLists.txt
File metadata and controls
457 lines (377 loc) · 16.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
cmake_minimum_required(VERSION 2.8)
project(Orthanc)
# Version of the build, should always be "mainline" except in release branches
set(ORTHANC_VERSION "mainline")
#####################################################################
## CMake parameters tunable at the command line
#####################################################################
# Parameters of the build
SET(STATIC_BUILD OFF CACHE BOOL "Static build of the third-party libraries (necessary for Windows)")
SET(STANDALONE_BUILD ON CACHE BOOL "Standalone build (all the resources are embedded, necessary for releases)")
SET(ENABLE_SSL ON CACHE BOOL "Include support for SSL")
SET(BUILD_CLIENT_LIBRARY ON CACHE BOOL "Build the client library")
SET(DCMTK_DICTIONARY_DIR "" CACHE PATH "Directory containing the DCMTK dictionaries \"dicom.dic\" and \"private.dic\" (only when using system version of DCMTK)")
SET(ALLOW_DOWNLOADS OFF CACHE BOOL "Allow CMake to download packages")
SET(UNIT_TESTS_WITH_HTTP_CONNEXIONS ON CACHE BOOL "Allow unit tests to make HTTP requests")
# Advanced parameters to fine-tune linking against system libraries
SET(USE_SYSTEM_JSONCPP ON CACHE BOOL "Use the system version of JsonCpp")
SET(USE_SYSTEM_GOOGLE_LOG ON CACHE BOOL "Use the system version of Google Log")
SET(USE_SYSTEM_GOOGLE_TEST ON CACHE BOOL "Use the system version of Google Test")
SET(USE_SYSTEM_SQLITE ON CACHE BOOL "Use the system version of SQLite")
SET(USE_SYSTEM_MONGOOSE ON CACHE BOOL "Use the system version of Mongoose")
SET(USE_SYSTEM_LUA ON CACHE BOOL "Use the system version of Lua")
SET(USE_SYSTEM_DCMTK ON CACHE BOOL "Use the system version of DCMTK")
SET(USE_SYSTEM_BOOST ON CACHE BOOL "Use the system version of Boost")
SET(USE_SYSTEM_LIBPNG ON CACHE BOOL "Use the system version of LibPng")
SET(USE_SYSTEM_CURL ON CACHE BOOL "Use the system version of LibCurl")
SET(USE_SYSTEM_OPENSSL ON CACHE BOOL "Use the system version of OpenSSL")
SET(USE_SYSTEM_ZLIB ON CACHE BOOL "Use the system version of ZLib")
# Distribution-specific settings
SET(USE_GTEST_DEBIAN_SOURCE_PACKAGE OFF CACHE BOOL "Use the sources of Google Test shipped with libgtest-dev (Debian only)")
mark_as_advanced(USE_GTEST_DEBIAN_SOURCE_PACKAGE)
# Some basic inclusions
include(CheckIncludeFiles)
include(CheckIncludeFileCXX)
include(CheckLibraryExists)
include(${CMAKE_SOURCE_DIR}/Resources/CMake/AutoGeneratedCode.cmake)
include(${CMAKE_SOURCE_DIR}/Resources/CMake/DownloadPackage.cmake)
include(${CMAKE_SOURCE_DIR}/Resources/CMake/Compiler.cmake)
set(ORTHANC_ROOT ${CMAKE_SOURCE_DIR})
#####################################################################
## Inclusion of third-party dependencies
#####################################################################
# Configuration of the standalone builds
if (CMAKE_CROSSCOMPILING)
# Cross-compilation implies the standalone build
SET(STANDALONE_BUILD ON)
endif()
# Prepare the third-party dependencies
SET(THIRD_PARTY_SOURCES
${CMAKE_SOURCE_DIR}/Resources/md5/md5.c
${CMAKE_SOURCE_DIR}/Resources/base64/base64.cpp
)
include(${CMAKE_SOURCE_DIR}/Resources/CMake/GoogleLogConfiguration.cmake)
include(${CMAKE_SOURCE_DIR}/Resources/CMake/BoostConfiguration.cmake)
include(${CMAKE_SOURCE_DIR}/Resources/CMake/DcmtkConfiguration.cmake)
include(${CMAKE_SOURCE_DIR}/Resources/CMake/MongooseConfiguration.cmake)
include(${CMAKE_SOURCE_DIR}/Resources/CMake/ZlibConfiguration.cmake)
include(${CMAKE_SOURCE_DIR}/Resources/CMake/SQLiteConfiguration.cmake)
include(${CMAKE_SOURCE_DIR}/Resources/CMake/JsonCppConfiguration.cmake)
include(${CMAKE_SOURCE_DIR}/Resources/CMake/LibPngConfiguration.cmake)
include(${CMAKE_SOURCE_DIR}/Resources/CMake/LuaConfiguration.cmake)
include(${CMAKE_SOURCE_DIR}/Resources/CMake/LibCurlConfiguration.cmake)
if (${ENABLE_SSL})
add_definitions(-DORTHANC_SSL_ENABLED=1)
include(${CMAKE_SOURCE_DIR}/Resources/CMake/OpenSslConfiguration.cmake)
else()
add_definitions(-DORTHANC_SSL_ENABLED=0)
endif()
#####################################################################
## Autogeneration of files
#####################################################################
# Prepare the embedded files
set(EMBEDDED_FILES
PREPARE_DATABASE ${CMAKE_CURRENT_SOURCE_DIR}/OrthancServer/PrepareDatabase.sql
UPGRADE_DATABASE_3_TO_4 ${CMAKE_CURRENT_SOURCE_DIR}/OrthancServer/Upgrade3To4.sql
CONFIGURATION_SAMPLE ${CMAKE_CURRENT_SOURCE_DIR}/Resources/Configuration.json
LUA_TOOLBOX ${CMAKE_CURRENT_SOURCE_DIR}/Resources/Toolbox.lua
)
if (${STANDALONE_BUILD})
# We embed all the resources in the binaries for standalone builds
add_definitions(-DORTHANC_STANDALONE=1)
EmbedResources(
${EMBEDDED_FILES}
ORTHANC_EXPLORER ${CMAKE_CURRENT_SOURCE_DIR}/OrthancExplorer
${DCMTK_DICTIONARIES}
)
else()
add_definitions(
-DORTHANC_STANDALONE=0
-DORTHANC_PATH=\"${CMAKE_SOURCE_DIR}\"
)
EmbedResources(
${EMBEDDED_FILES}
)
endif()
#####################################################################
## Build the core of Orthanc
#####################################################################
add_definitions(
-DORTHANC_VERSION="${ORTHANC_VERSION}"
)
list(LENGTH OPENSSL_SOURCES OPENSSL_SOURCES_LENGTH)
if (${OPENSSL_SOURCES_LENGTH} GREATER 0)
add_library(OpenSSL STATIC ${OPENSSL_SOURCES})
endif()
add_library(CoreLibrary
STATIC
${AUTOGENERATED_SOURCES}
${THIRD_PARTY_SOURCES}
${CURL_SOURCES}
Core/Cache/MemoryCache.cpp
Core/ChunkedBuffer.cpp
Core/Compression/BufferCompressor.cpp
Core/Compression/ZlibCompressor.cpp
Core/Compression/ZipWriter.cpp
Core/Compression/HierarchicalZipWriter.cpp
Core/OrthancException.cpp
Core/DicomFormat/DicomArray.cpp
Core/DicomFormat/DicomMap.cpp
Core/DicomFormat/DicomTag.cpp
Core/DicomFormat/DicomIntegerPixelAccessor.cpp
Core/DicomFormat/DicomInstanceHasher.cpp
Core/Enumerations.cpp
Core/FileStorage/FileStorage.cpp
Core/FileStorage/StorageAccessor.cpp
Core/FileStorage/CompressedFileStorageAccessor.cpp
Core/FileStorage/FileStorageAccessor.cpp
Core/HttpClient.cpp
Core/HttpServer/EmbeddedResourceHttpHandler.cpp
Core/HttpServer/FilesystemHttpHandler.cpp
Core/HttpServer/HttpHandler.cpp
Core/HttpServer/HttpOutput.cpp
Core/HttpServer/MongooseServer.cpp
Core/HttpServer/HttpFileSender.cpp
Core/HttpServer/FilesystemHttpSender.cpp
Core/RestApi/RestApiPath.cpp
Core/RestApi/RestApiOutput.cpp
Core/RestApi/RestApi.cpp
Core/MultiThreading/ArrayFilledByThreads.cpp
Core/MultiThreading/BagOfRunnablesBySteps.cpp
Core/MultiThreading/Mutex.cpp
Core/MultiThreading/ReaderWriterLock.cpp
Core/MultiThreading/SharedMessageQueue.cpp
Core/MultiThreading/ThreadedCommandProcessor.cpp
Core/ImageFormats/ImageAccessor.cpp
Core/ImageFormats/ImageBuffer.cpp
Core/ImageFormats/PngReader.cpp
Core/ImageFormats/PngWriter.cpp
Core/SQLite/Connection.cpp
Core/SQLite/FunctionContext.cpp
Core/SQLite/Statement.cpp
Core/SQLite/StatementId.cpp
Core/SQLite/StatementReference.cpp
Core/SQLite/Transaction.cpp
Core/Toolbox.cpp
Core/Uuid.cpp
Core/Lua/LuaContext.cpp
Core/Lua/LuaFunctionCall.cpp
OrthancCppClient/OrthancConnection.cpp
OrthancCppClient/Study.cpp
OrthancCppClient/Series.cpp
OrthancCppClient/Instance.cpp
OrthancCppClient/Patient.cpp
)
#####################################################################
## Build the Orthanc server
#####################################################################
add_library(ServerLibrary
STATIC
${DCMTK_SOURCES}
OrthancServer/DicomProtocol/DicomFindAnswers.cpp
OrthancServer/DicomProtocol/DicomServer.cpp
OrthancServer/DicomProtocol/DicomUserConnection.cpp
OrthancServer/DicomProtocol/RemoteModalityParameters.cpp
OrthancServer/DicomProtocol/ReusableDicomUserConnection.cpp
OrthancServer/DicomModification.cpp
OrthancServer/FromDcmtkBridge.cpp
OrthancServer/ParsedDicomFile.cpp
OrthancServer/Internals/CommandDispatcher.cpp
OrthancServer/Internals/FindScp.cpp
OrthancServer/Internals/MoveScp.cpp
OrthancServer/Internals/StoreScp.cpp
OrthancServer/OrthancInitialization.cpp
OrthancServer/OrthancPeerParameters.cpp
OrthancServer/OrthancRestApi/OrthancRestAnonymizeModify.cpp
OrthancServer/OrthancRestApi/OrthancRestApi.cpp
OrthancServer/OrthancRestApi/OrthancRestArchive.cpp
OrthancServer/OrthancRestApi/OrthancRestChanges.cpp
OrthancServer/OrthancRestApi/OrthancRestModalities.cpp
OrthancServer/OrthancRestApi/OrthancRestResources.cpp
OrthancServer/OrthancRestApi/OrthancRestSystem.cpp
OrthancServer/ServerIndex.cpp
OrthancServer/ToDcmtkBridge.cpp
OrthancServer/DatabaseWrapper.cpp
OrthancServer/ServerContext.cpp
OrthancServer/ServerEnumerations.cpp
OrthancServer/ServerToolbox.cpp
OrthancServer/OrthancFindRequestHandler.cpp
OrthancServer/OrthancMoveRequestHandler.cpp
)
# Ensure autogenerated code is built before building ServerLibrary
add_dependencies(ServerLibrary CoreLibrary)
add_executable(Orthanc
OrthancServer/main.cpp
)
target_link_libraries(Orthanc ServerLibrary CoreLibrary)
if (${OPENSSL_SOURCES_LENGTH} GREATER 0)
target_link_libraries(Orthanc OpenSSL)
endif()
install(
TARGETS Orthanc
RUNTIME DESTINATION sbin
)
#####################################################################
## Build the unit tests
#####################################################################
if (UNIT_TESTS_WITH_HTTP_CONNEXIONS)
add_definitions(-DUNIT_TESTS_WITH_HTTP_CONNEXIONS=1)
else()
add_definitions(-DUNIT_TESTS_WITH_HTTP_CONNEXIONS=0)
endif()
add_definitions(-DORTHANC_BUILD_UNIT_TESTS=1)
include(${CMAKE_SOURCE_DIR}/Resources/CMake/GoogleTestConfiguration.cmake)
add_executable(UnitTests
${GTEST_SOURCES}
UnitTestsSources/DicomMap.cpp
UnitTestsSources/FileStorage.cpp
UnitTestsSources/FromDcmtk.cpp
UnitTestsSources/MemoryCache.cpp
UnitTestsSources/Png.cpp
UnitTestsSources/RestApi.cpp
UnitTestsSources/SQLite.cpp
UnitTestsSources/SQLiteChromium.cpp
UnitTestsSources/ServerIndexTests.cpp
UnitTestsSources/Versions.cpp
UnitTestsSources/Zip.cpp
UnitTestsSources/Lua.cpp
UnitTestsSources/MultiThreading.cpp
UnitTestsSources/UnitTestsMain.cpp
)
target_link_libraries(UnitTests ServerLibrary CoreLibrary)
if (${OPENSSL_SOURCES_LENGTH} GREATER 0)
target_link_libraries(UnitTests OpenSSL)
endif()
#####################################################################
## Create the standalone DLL containing the Orthanc Client API
#####################################################################
if (BUILD_CLIENT_LIBRARY)
include_directories(${ORTHANC_ROOT}/OrthancCppClient/SharedLibrary/Laaw)
if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
if (CMAKE_CROSSCOMPILING)
# Remove the default "lib" prefix from "libOrthancClient.dll" if cross-compiling
set(CMAKE_SHARED_LIBRARY_PREFIX "")
if (${CMAKE_SIZEOF_VOID_P} EQUAL 4)
set(ORTHANC_CPP_CLIENT_AUX ${ORTHANC_ROOT}/OrthancCppClient/SharedLibrary/AUTOGENERATED/Windows32.def)
elseif (${CMAKE_SIZEOF_VOID_P} EQUAL 8)
set(ORTHANC_CPP_CLIENT_AUX ${ORTHANC_ROOT}/OrthancCppClient/SharedLibrary/AUTOGENERATED/Windows64.def)
else()
message(FATAL_ERROR "Support your platform here")
endif()
else()
# Nothing to do if using Visual Studio
endif()
if (${CMAKE_SIZEOF_VOID_P} EQUAL 4)
set(CMAKE_SHARED_LIBRARY_SUFFIX "_Windows32.dll")
list(APPEND ORTHANC_CPP_CLIENT_AUX ${ORTHANC_ROOT}/OrthancCppClient/SharedLibrary/AUTOGENERATED/Windows32.rc)
elseif (${CMAKE_SIZEOF_VOID_P} EQUAL 8)
set(CMAKE_SHARED_LIBRARY_SUFFIX "_Windows64.dll")
list(APPEND ORTHANC_CPP_CLIENT_AUX ${ORTHANC_ROOT}/OrthancCppClient/SharedLibrary/AUTOGENERATED/Windows64.rc)
else()
message(FATAL_ERROR "Support your platform here")
endif()
else()
set(ORTHANC_CPP_CLIENT_AUX ${OPENSSL_SOURCES})
endif()
add_library(OrthancClient SHARED
${ORTHANC_ROOT}/Core/OrthancException.cpp
${ORTHANC_ROOT}/Core/Enumerations.cpp
${ORTHANC_ROOT}/Core/Toolbox.cpp
${ORTHANC_ROOT}/Core/HttpClient.cpp
${ORTHANC_ROOT}/Core/MultiThreading/ArrayFilledByThreads.cpp
${ORTHANC_ROOT}/Core/MultiThreading/ThreadedCommandProcessor.cpp
${ORTHANC_ROOT}/Core/MultiThreading/SharedMessageQueue.cpp
${ORTHANC_ROOT}/Core/ImageFormats/ImageAccessor.cpp
${ORTHANC_ROOT}/Core/ImageFormats/ImageBuffer.cpp
${ORTHANC_ROOT}/Core/ImageFormats/PngReader.cpp
${ORTHANC_ROOT}/OrthancCppClient/OrthancConnection.cpp
${ORTHANC_ROOT}/OrthancCppClient/Series.cpp
${ORTHANC_ROOT}/OrthancCppClient/Study.cpp
${ORTHANC_ROOT}/OrthancCppClient/Instance.cpp
${ORTHANC_ROOT}/OrthancCppClient/Patient.cpp
${ORTHANC_ROOT}/OrthancCppClient/SharedLibrary/SharedLibrary.cpp
${ORTHANC_ROOT}/Resources/md5/md5.c
${ORTHANC_ROOT}/Resources/base64/base64.cpp
${ORTHANC_CPP_CLIENT_AUX}
${THIRD_PARTY_SOURCES}
${CURL_SOURCES}
)
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
set_target_properties(OrthancClient
PROPERTIES LINK_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined -Wl,--as-needed -Wl,--version-script=${ORTHANC_ROOT}/OrthancCppClient/SharedLibrary/Laaw/VersionScript.map"
)
target_link_libraries(OrthancClient pthread)
elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
target_link_libraries(OrthancClient OpenSSL ws2_32)
if (CMAKE_CROSSCOMPILING)
set_target_properties(OrthancClient
PROPERTIES LINK_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--allow-multiple-definition -static-libgcc -static-libstdc++"
)
endif()
else()
message(FATAL_ERROR "Support your platform here")
endif()
# Set the version of the "Orthanc Client" shared library
file(STRINGS
${CMAKE_SOURCE_DIR}/OrthancCppClient/SharedLibrary/Product.json
ORTHANC_CLIENT_VERSION_TMP
REGEX "^[ \t]*\"Version\"[ \t]*")
string(REGEX REPLACE "^.*\"([0-9]+)\\.([0-9]+)\\.([0-9]+)\"" "\\1.\\2"
ORTHANC_CLIENT_VERSION ${ORTHANC_CLIENT_VERSION_TMP})
message("Setting the version of the library to ${ORTHANC_CLIENT_VERSION}")
set_target_properties(OrthancClient PROPERTIES
VERSION ${ORTHANC_CLIENT_VERSION}
SOVERSION ${ORTHANC_CLIENT_VERSION})
install(
TARGETS OrthancClient
RUNTIME DESTINATION lib # Destination for Windows
LIBRARY DESTINATION lib # Destination for Linux
)
install(
FILES ${ORTHANC_ROOT}/OrthancCppClient/SharedLibrary/AUTOGENERATED/OrthancCppClient.h
DESTINATION include/orthanc
)
endif()
#####################################################################
## Generate the documentation if Doxygen is present
#####################################################################
find_package(Doxygen)
if (DOXYGEN_FOUND)
configure_file(
${CMAKE_SOURCE_DIR}/Resources/Orthanc.doxygen
${CMAKE_CURRENT_BINARY_DIR}/Orthanc.doxygen
@ONLY)
add_custom_target(doc
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Orthanc.doxygen
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating internal documentation with Doxygen" VERBATIM
)
if (BUILD_CLIENT_LIBRARY)
configure_file(
${CMAKE_SOURCE_DIR}/Resources/OrthancClient.doxygen
${CMAKE_CURRENT_BINARY_DIR}/OrthancClient.doxygen
@ONLY)
add_custom_command(TARGET OrthancClient
POST_BUILD
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/OrthancClient.doxygen
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating client documentation with Doxygen" VERBATIM
)
install(
DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/OrthancClientDocumentation/doc/
DESTINATION share/doc/orthanc/OrthancClient
)
endif()
else()
message("Doxygen not found. The documentation will not be built.")
endif()
#####################################################################
## Prepare the "uninstall" target
## http://www.cmake.org/Wiki/CMake_FAQ#Can_I_do_.22make_uninstall.22_with_CMake.3F
#####################################################################
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/Resources/CMake/Uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)