comparison OrthancServer/CMakeLists.txt @ 4540:9c0cff7a6ca2 db-changes

integration mainline->db-changes
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 02 Mar 2021 16:51:19 +0100
parents f5cb0c0ffbed
children 1d96fe7e054e
comparison
equal deleted inserted replaced
3141:f2b300e46755 4540:9c0cff7a6ca2
1 # Orthanc - A Lightweight, RESTful DICOM Store
2 # Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
3 # Department, University Hospital of Liege, Belgium
4 # Copyright (C) 2017-2021 Osimis S.A., Belgium
5 #
6 # This program is free software: you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License as
8 # published by the Free Software Foundation, either version 3 of the
9 # License, or (at your option) any later version.
10 #
11 # In addition, as a special exception, the copyright holders of this
12 # program give permission to link the code of its release with the
13 # OpenSSL project's "OpenSSL" library (or with modified versions of it
14 # that use the same license as the "OpenSSL" library), and distribute
15 # the linked executables. You must obey the GNU General Public License
16 # in all respects for all of the code used other than "OpenSSL". If you
17 # modify file(s) with this exception, you may extend this exception to
18 # your version of the file(s), but you are not obligated to do so. If
19 # you do not wish to do so, delete this exception statement from your
20 # version. If you delete this exception statement from all source files
21 # in the program, then also delete it here.
22 #
23 # This program is distributed in the hope that it will be useful, but
24 # WITHOUT ANY WARRANTY; without even the implied warranty of
25 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
26 # General Public License for more details.
27 #
28 # You should have received a copy of the GNU General Public License
29 # along with this program. If not, see <http://www.gnu.org/licenses/>.
30
31
32 cmake_minimum_required(VERSION 2.8)
33 cmake_policy(SET CMP0058 NEW)
34
35 project(Orthanc)
36
37
38 #####################################################################
39 ## Generic parameters of the Orthanc framework
40 #####################################################################
41
42 include(${CMAKE_SOURCE_DIR}/../OrthancFramework/Resources/CMake/OrthancFrameworkParameters.cmake)
43
44 # Enable all the optional components of the Orthanc framework
45 set(ENABLE_CRYPTO_OPTIONS ON)
46 set(ENABLE_DCMTK ON)
47 set(ENABLE_DCMTK_NETWORKING ON)
48 set(ENABLE_DCMTK_TRANSCODING ON)
49 set(ENABLE_GOOGLE_TEST ON)
50 set(ENABLE_JPEG ON)
51 set(ENABLE_LOCALE ON)
52 set(ENABLE_LUA ON)
53 set(ENABLE_OPENSSL_ENGINES ON) # OpenSSL engines are necessary for PKCS11
54 set(ENABLE_PNG ON)
55 set(ENABLE_PUGIXML ON)
56 set(ENABLE_SQLITE ON)
57 set(ENABLE_WEB_CLIENT ON)
58 set(ENABLE_WEB_SERVER ON)
59 set(ENABLE_ZLIB ON)
60
61
62 #####################################################################
63 ## CMake parameters tunable at the command line to configure the
64 ## plugins, the companion tools, and the unit tests
65 #####################################################################
66
67 # Parameters of the build
68 set(STANDALONE_BUILD ON CACHE BOOL "Standalone build (all the resources are embedded, necessary for releases)")
69 SET(BUILD_MODALITY_WORKLISTS ON CACHE BOOL "Whether to build the sample plugin to serve modality worklists")
70 SET(BUILD_RECOVER_COMPRESSED_FILE ON CACHE BOOL "Whether to build the companion tool to recover files compressed using Orthanc")
71 SET(BUILD_SERVE_FOLDERS ON CACHE BOOL "Whether to build the ServeFolders plugin")
72 SET(BUILD_CONNECTIVITY_CHECKS ON CACHE BOOL "Whether to build the ConnectivityChecks plugin")
73 SET(ENABLE_PLUGINS ON CACHE BOOL "Enable plugins")
74 SET(UNIT_TESTS_WITH_HTTP_CONNEXIONS ON CACHE BOOL "Allow unit tests to make HTTP requests")
75
76
77 #####################################################################
78 ## Configuration of the Orthanc framework
79 #####################################################################
80
81 include(${CMAKE_SOURCE_DIR}/../OrthancFramework/Resources/CMake/VisualStudioPrecompiledHeaders.cmake)
82 include(${CMAKE_SOURCE_DIR}/../OrthancFramework/Resources/CMake/OrthancFrameworkConfiguration.cmake)
83
84 # To export the proper symbols in the sample plugins
85 include(${CMAKE_SOURCE_DIR}/Plugins/Samples/Common/OrthancPluginsExports.cmake)
86
87
88 #####################################################################
89 ## List of source files
90 #####################################################################
91
92 set(ORTHANC_SERVER_SOURCES
93 ${CMAKE_SOURCE_DIR}/Sources/Database/Compatibility/DatabaseLookup.cpp
94 ${CMAKE_SOURCE_DIR}/Sources/Database/Compatibility/ICreateInstance.cpp
95 ${CMAKE_SOURCE_DIR}/Sources/Database/Compatibility/IGetChildrenMetadata.cpp
96 ${CMAKE_SOURCE_DIR}/Sources/Database/Compatibility/ILookupResourceAndParent.cpp
97 ${CMAKE_SOURCE_DIR}/Sources/Database/Compatibility/ILookupResources.cpp
98 ${CMAKE_SOURCE_DIR}/Sources/Database/Compatibility/SetOfResources.cpp
99 ${CMAKE_SOURCE_DIR}/Sources/Database/ResourcesContent.cpp
100 ${CMAKE_SOURCE_DIR}/Sources/Database/SQLiteDatabaseWrapper.cpp
101 ${CMAKE_SOURCE_DIR}/Sources/DicomInstanceOrigin.cpp
102 ${CMAKE_SOURCE_DIR}/Sources/DicomInstanceToStore.cpp
103 ${CMAKE_SOURCE_DIR}/Sources/EmbeddedResourceHttpHandler.cpp
104 ${CMAKE_SOURCE_DIR}/Sources/ExportedResource.cpp
105 ${CMAKE_SOURCE_DIR}/Sources/LuaScripting.cpp
106 ${CMAKE_SOURCE_DIR}/Sources/OrthancConfiguration.cpp
107 ${CMAKE_SOURCE_DIR}/Sources/OrthancFindRequestHandler.cpp
108 ${CMAKE_SOURCE_DIR}/Sources/OrthancGetRequestHandler.cpp
109 ${CMAKE_SOURCE_DIR}/Sources/OrthancHttpHandler.cpp
110 ${CMAKE_SOURCE_DIR}/Sources/OrthancInitialization.cpp
111 ${CMAKE_SOURCE_DIR}/Sources/OrthancMoveRequestHandler.cpp
112 ${CMAKE_SOURCE_DIR}/Sources/OrthancRestApi/OrthancRestAnonymizeModify.cpp
113 ${CMAKE_SOURCE_DIR}/Sources/OrthancRestApi/OrthancRestApi.cpp
114 ${CMAKE_SOURCE_DIR}/Sources/OrthancRestApi/OrthancRestArchive.cpp
115 ${CMAKE_SOURCE_DIR}/Sources/OrthancRestApi/OrthancRestChanges.cpp
116 ${CMAKE_SOURCE_DIR}/Sources/OrthancRestApi/OrthancRestModalities.cpp
117 ${CMAKE_SOURCE_DIR}/Sources/OrthancRestApi/OrthancRestResources.cpp
118 ${CMAKE_SOURCE_DIR}/Sources/OrthancRestApi/OrthancRestSystem.cpp
119 ${CMAKE_SOURCE_DIR}/Sources/OrthancWebDav.cpp
120 ${CMAKE_SOURCE_DIR}/Sources/QueryRetrieveHandler.cpp
121 ${CMAKE_SOURCE_DIR}/Sources/Search/DatabaseConstraint.cpp
122 ${CMAKE_SOURCE_DIR}/Sources/Search/DatabaseLookup.cpp
123 ${CMAKE_SOURCE_DIR}/Sources/Search/DicomTagConstraint.cpp
124 ${CMAKE_SOURCE_DIR}/Sources/Search/HierarchicalMatcher.cpp
125 ${CMAKE_SOURCE_DIR}/Sources/Search/ISqlLookupFormatter.cpp
126 ${CMAKE_SOURCE_DIR}/Sources/ServerContext.cpp
127 ${CMAKE_SOURCE_DIR}/Sources/ServerEnumerations.cpp
128 ${CMAKE_SOURCE_DIR}/Sources/ServerIndex.cpp
129 ${CMAKE_SOURCE_DIR}/Sources/ServerJobs/ArchiveJob.cpp
130 ${CMAKE_SOURCE_DIR}/Sources/ServerJobs/CleaningInstancesJob.cpp
131 ${CMAKE_SOURCE_DIR}/Sources/ServerJobs/DicomModalityStoreJob.cpp
132 ${CMAKE_SOURCE_DIR}/Sources/ServerJobs/DicomMoveScuJob.cpp
133 ${CMAKE_SOURCE_DIR}/Sources/ServerJobs/LuaJobManager.cpp
134 ${CMAKE_SOURCE_DIR}/Sources/ServerJobs/MergeStudyJob.cpp
135 ${CMAKE_SOURCE_DIR}/Sources/ServerJobs/Operations/DeleteResourceOperation.cpp
136 ${CMAKE_SOURCE_DIR}/Sources/ServerJobs/Operations/DicomInstanceOperationValue.cpp
137 ${CMAKE_SOURCE_DIR}/Sources/ServerJobs/Operations/ModifyInstanceOperation.cpp
138 ${CMAKE_SOURCE_DIR}/Sources/ServerJobs/Operations/StorePeerOperation.cpp
139 ${CMAKE_SOURCE_DIR}/Sources/ServerJobs/Operations/StoreScuOperation.cpp
140 ${CMAKE_SOURCE_DIR}/Sources/ServerJobs/Operations/SystemCallOperation.cpp
141 ${CMAKE_SOURCE_DIR}/Sources/ServerJobs/OrthancJobUnserializer.cpp
142 ${CMAKE_SOURCE_DIR}/Sources/ServerJobs/OrthancPeerStoreJob.cpp
143 ${CMAKE_SOURCE_DIR}/Sources/ServerJobs/ResourceModificationJob.cpp
144 ${CMAKE_SOURCE_DIR}/Sources/ServerJobs/SplitStudyJob.cpp
145 ${CMAKE_SOURCE_DIR}/Sources/ServerJobs/StorageCommitmentScpJob.cpp
146 ${CMAKE_SOURCE_DIR}/Sources/ServerToolbox.cpp
147 ${CMAKE_SOURCE_DIR}/Sources/SliceOrdering.cpp
148 ${CMAKE_SOURCE_DIR}/Sources/StorageCommitmentReports.cpp
149 )
150
151
152 set(ORTHANC_FRAMEWORK_UNIT_TESTS
153 ${CMAKE_SOURCE_DIR}/../OrthancFramework/UnitTestsSources/DicomMapTests.cpp
154 ${CMAKE_SOURCE_DIR}/../OrthancFramework/UnitTestsSources/FileStorageTests.cpp
155 ${CMAKE_SOURCE_DIR}/../OrthancFramework/UnitTestsSources/FrameworkTests.cpp
156 ${CMAKE_SOURCE_DIR}/../OrthancFramework/UnitTestsSources/FromDcmtkTests.cpp
157 ${CMAKE_SOURCE_DIR}/../OrthancFramework/UnitTestsSources/ImageProcessingTests.cpp
158 ${CMAKE_SOURCE_DIR}/../OrthancFramework/UnitTestsSources/ImageTests.cpp
159 ${CMAKE_SOURCE_DIR}/../OrthancFramework/UnitTestsSources/JobsTests.cpp
160 ${CMAKE_SOURCE_DIR}/../OrthancFramework/UnitTestsSources/JpegLosslessTests.cpp
161 ${CMAKE_SOURCE_DIR}/../OrthancFramework/UnitTestsSources/LoggingTests.cpp
162 ${CMAKE_SOURCE_DIR}/../OrthancFramework/UnitTestsSources/LuaTests.cpp
163 ${CMAKE_SOURCE_DIR}/../OrthancFramework/UnitTestsSources/MemoryCacheTests.cpp
164 ${CMAKE_SOURCE_DIR}/../OrthancFramework/UnitTestsSources/RestApiTests.cpp
165 ${CMAKE_SOURCE_DIR}/../OrthancFramework/UnitTestsSources/SQLiteChromiumTests.cpp
166 ${CMAKE_SOURCE_DIR}/../OrthancFramework/UnitTestsSources/SQLiteTests.cpp
167 ${CMAKE_SOURCE_DIR}/../OrthancFramework/UnitTestsSources/StreamTests.cpp
168 ${CMAKE_SOURCE_DIR}/../OrthancFramework/UnitTestsSources/ToolboxTests.cpp
169 ${CMAKE_SOURCE_DIR}/../OrthancFramework/UnitTestsSources/ZipTests.cpp
170 )
171
172 set(ORTHANC_SERVER_UNIT_TESTS
173 ${CMAKE_SOURCE_DIR}/UnitTestsSources/DatabaseLookupTests.cpp
174 ${CMAKE_SOURCE_DIR}/UnitTestsSources/LuaServerTests.cpp
175 ${CMAKE_SOURCE_DIR}/UnitTestsSources/PluginsTests.cpp
176 ${CMAKE_SOURCE_DIR}/UnitTestsSources/ServerIndexTests.cpp
177 ${CMAKE_SOURCE_DIR}/UnitTestsSources/ServerJobsTests.cpp
178 ${CMAKE_SOURCE_DIR}/UnitTestsSources/SizeOfTests.cpp
179 ${CMAKE_SOURCE_DIR}/UnitTestsSources/UnitTestsMain.cpp
180 ${CMAKE_SOURCE_DIR}/UnitTestsSources/VersionsTests.cpp
181 )
182
183
184 if (ENABLE_PLUGINS)
185 include_directories(${CMAKE_SOURCE_DIR}/Plugins/Include)
186
187 list(APPEND ORTHANC_SERVER_SOURCES
188 ${CMAKE_SOURCE_DIR}/Plugins/Engine/OrthancPluginDatabase.cpp
189 ${CMAKE_SOURCE_DIR}/Plugins/Engine/OrthancPlugins.cpp
190 ${CMAKE_SOURCE_DIR}/Plugins/Engine/PluginsEnumerations.cpp
191 ${CMAKE_SOURCE_DIR}/Plugins/Engine/PluginsErrorDictionary.cpp
192 ${CMAKE_SOURCE_DIR}/Plugins/Engine/PluginsJob.cpp
193 ${CMAKE_SOURCE_DIR}/Plugins/Engine/PluginsManager.cpp
194 )
195
196 list(APPEND ORTHANC_SERVER_UNIT_TESTS
197 ${CMAKE_SOURCE_DIR}/UnitTestsSources/PluginsTests.cpp
198 )
199 endif()
200
201
202 if (CMAKE_COMPILER_IS_GNUCXX
203 AND NOT CMAKE_CROSSCOMPILING
204 AND DCMTK_STATIC_VERSION STREQUAL "3.6.0")
205 # Add the "-pedantic" flag only on the Orthanc sources, and only if
206 # cross-compiling DCMTK 3.6.0
207 set(ORTHANC_ALL_SOURCES
208 ${ORTHANC_CORE_SOURCES_INTERNAL}
209 ${ORTHANC_DICOM_SOURCES_INTERNAL}
210 ${ORTHANC_SERVER_SOURCES}
211 ${ORTHANC_FRAMEWORK_UNIT_TESTS}
212 ${ORTHANC_SERVER_UNIT_TESTS}
213 ${CMAKE_SOURCE_DIR}/Plugins/Samples/ModalityWorklists/Plugin.cpp
214 ${CMAKE_SOURCE_DIR}/Plugins/Samples/ServeFolders/Plugin.cpp
215 ${CMAKE_SOURCE_DIR}/Sources/EmbeddedResourceHttpHandler.cpp
216 ${CMAKE_SOURCE_DIR}/Sources/main.cpp
217 )
218
219 set_source_files_properties(${ORTHANC_ALL_SOURCES}
220 PROPERTIES COMPILE_FLAGS -pedantic
221 )
222 endif()
223
224
225 #####################################################################
226 ## Autogeneration of files
227 #####################################################################
228
229 set(ORTHANC_EMBEDDED_FILES
230 CONFIGURATION_SAMPLE ${CMAKE_SOURCE_DIR}/Resources/Configuration.json
231 DICOM_CONFORMANCE_STATEMENT ${CMAKE_SOURCE_DIR}/Resources/DicomConformanceStatement.txt
232 FONT_UBUNTU_MONO_BOLD_16 ${CMAKE_SOURCE_DIR}/Resources/Fonts/UbuntuMonoBold-16.json
233 LUA_TOOLBOX ${CMAKE_SOURCE_DIR}/Resources/Toolbox.lua
234 PREPARE_DATABASE ${CMAKE_SOURCE_DIR}/Sources/Database/PrepareDatabase.sql
235 UPGRADE_DATABASE_3_TO_4 ${CMAKE_SOURCE_DIR}/Sources/Database/Upgrade3To4.sql
236 UPGRADE_DATABASE_4_TO_5 ${CMAKE_SOURCE_DIR}/Sources/Database/Upgrade4To5.sql
237
238 INSTALL_TRACK_ATTACHMENTS_SIZE
239 ${CMAKE_SOURCE_DIR}/Sources/Database/InstallTrackAttachmentsSize.sql
240 )
241
242 if (STANDALONE_BUILD)
243 # We embed all the resources in the binaries for standalone builds
244 add_definitions(
245 -DORTHANC_STANDALONE=1
246 )
247
248 list(APPEND ORTHANC_EMBEDDED_FILES
249 ORTHANC_EXPLORER ${CMAKE_SOURCE_DIR}/OrthancExplorer
250 )
251 else()
252 add_definitions(
253 -DORTHANC_PATH=\"${CMAKE_SOURCE_DIR}\"
254 -DORTHANC_STANDALONE=0
255 )
256 endif()
257
258 EmbedResources(
259 --namespace=Orthanc.ServerResources
260 --target=OrthancServerResources
261 --framework-path=${CMAKE_SOURCE_DIR}/../OrthancFramework/Sources
262 ${ORTHANC_EMBEDDED_FILES}
263 )
264
265
266 if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
267 execute_process(
268 COMMAND
269 ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/../OrthancFramework/Resources/WindowsResources.py
270 ${ORTHANC_VERSION} Orthanc Orthanc.exe "Lightweight, RESTful DICOM server for medical imaging"
271 ERROR_VARIABLE Failure
272 OUTPUT_FILE ${AUTOGENERATED_DIR}/Orthanc.rc
273 )
274
275 if (Failure)
276 message(FATAL_ERROR "Error while computing the version information: ${Failure}")
277 endif()
278
279 list(APPEND ORTHANC_RESOURCES ${AUTOGENERATED_DIR}/Orthanc.rc)
280 endif()
281
282
283
284 #####################################################################
285 ## Configuration of the C/C++ macros
286 #####################################################################
287
288 check_symbol_exists(mallopt "malloc.h" HAVE_MALLOPT)
289
290 if (HAVE_MALLOPT)
291 add_definitions(-DHAVE_MALLOPT=1)
292 else()
293 add_definitions(-DHAVE_MALLOPT=0)
294 endif()
295
296
297 if (STATIC_BUILD)
298 add_definitions(-DORTHANC_STATIC=1)
299 else()
300 add_definitions(-DORTHANC_STATIC=0)
301 endif()
302
303
304 if (ENABLE_PLUGINS)
305 add_definitions(-DORTHANC_ENABLE_PLUGINS=1)
306 else()
307 add_definitions(-DORTHANC_ENABLE_PLUGINS=0)
308 endif()
309
310
311 if (UNIT_TESTS_WITH_HTTP_CONNEXIONS)
312 add_definitions(-DUNIT_TESTS_WITH_HTTP_CONNEXIONS=1)
313 else()
314 add_definitions(-DUNIT_TESTS_WITH_HTTP_CONNEXIONS=0)
315 endif()
316
317
318 add_definitions(
319 -DORTHANC_BUILD_UNIT_TESTS=1
320 -DORTHANC_BUILDING_SERVER_LIBRARY=1
321
322 # Macros for the plugins
323 -DHAS_ORTHANC_EXCEPTION=0
324 -DMODALITY_WORKLISTS_VERSION="${ORTHANC_VERSION}"
325 -DSERVE_FOLDERS_VERSION="${ORTHANC_VERSION}"
326 )
327
328
329 # Setup precompiled headers for Microsoft Visual Studio
330
331 # WARNING: There must be NO MORE "add_definitions()", "include()" or
332 # "include_directories()" below, otherwise the generated precompiled
333 # headers might get broken!
334
335 if (MSVC)
336 add_definitions(-DORTHANC_USE_PRECOMPILED_HEADERS=1)
337
338 set(TMP
339 ${ORTHANC_CORE_SOURCES_INTERNAL}
340 ${ORTHANC_DICOM_SOURCES_INTERNAL}
341 )
342
343 ADD_VISUAL_STUDIO_PRECOMPILED_HEADERS(
344 "PrecompiledHeaders.h" "${CMAKE_SOURCE_DIR}/../OrthancFramework/Sources/PrecompiledHeaders.cpp"
345 TMP ORTHANC_CORE_PCH)
346
347 ADD_VISUAL_STUDIO_PRECOMPILED_HEADERS(
348 "PrecompiledHeadersServer.h" "${CMAKE_SOURCE_DIR}/Sources/PrecompiledHeadersServer.cpp"
349 ORTHANC_SERVER_SOURCES ORTHANC_SERVER_PCH)
350
351 ADD_VISUAL_STUDIO_PRECOMPILED_HEADERS(
352 "PrecompiledHeadersUnitTests.h" "${CMAKE_SOURCE_DIR}/UnitTestsSources/PrecompiledHeadersUnitTests.cpp"
353 ORTHANC_SERVER_UNIT_TESTS ORTHANC_UNIT_TESTS_PCH)
354 endif()
355
356
357
358 #####################################################################
359 ## Build the core of Orthanc
360 #####################################################################
361
362 # "CoreLibrary" contains all the third-party dependencies and the
363 # content of the "Core" folder
364 add_library(CoreLibrary
365 STATIC
366 ${ORTHANC_CORE_PCH}
367 ${ORTHANC_CORE_SOURCES}
368 ${ORTHANC_DICOM_SOURCES}
369 ${AUTOGENERATED_SOURCES}
370 )
371
372 if (LIBICU_LIBRARIES)
373 target_link_libraries(CoreLibrary ${LIBICU_LIBRARIES})
374 endif()
375
376
377 #####################################################################
378 ## Build the Orthanc server
379 #####################################################################
380
381 add_library(ServerLibrary
382 STATIC
383 ${ORTHANC_SERVER_PCH}
384 ${ORTHANC_SERVER_SOURCES}
385 )
386
387 # Ensure autogenerated code is built before building ServerLibrary
388 add_dependencies(ServerLibrary CoreLibrary)
389
390 add_executable(Orthanc
391 ${CMAKE_SOURCE_DIR}/Sources/main.cpp
392 ${ORTHANC_RESOURCES}
393 )
394
395 target_link_libraries(Orthanc ServerLibrary CoreLibrary ${DCMTK_LIBRARIES})
396
397 install(
398 TARGETS Orthanc
399 RUNTIME DESTINATION sbin
400 )
401
402
403 #####################################################################
404 ## Build the unit tests
405 #####################################################################
406
407 add_executable(UnitTests
408 ${GOOGLE_TEST_SOURCES}
409 ${ORTHANC_UNIT_TESTS_PCH}
410 ${ORTHANC_FRAMEWORK_UNIT_TESTS}
411 ${ORTHANC_SERVER_UNIT_TESTS}
412 ${BOOST_EXTENDED_SOURCES}
413 )
414
415 target_link_libraries(UnitTests
416 ServerLibrary
417 CoreLibrary
418 ${DCMTK_LIBRARIES}
419 ${GOOGLE_TEST_LIBRARIES}
420 )
421
422
423 #####################################################################
424 ## Build a static library to share code between the plugins
425 #####################################################################
426
427 if (ENABLE_PLUGINS AND
428 (BUILD_SERVE_FOLDERS OR BUILD_MODALITY_WORKLISTS))
429 add_library(ThirdPartyPlugins STATIC
430 ${BOOST_SOURCES}
431 ${JSONCPP_SOURCES}
432 ${LIBICONV_SOURCES}
433 ${LIBICU_SOURCES}
434 Plugins/Samples/Common/OrthancPluginCppWrapper.cpp
435 )
436
437 if (LIBICU_LIBRARIES)
438 target_link_libraries(ThirdPartyPlugins ${LIBICU_LIBRARIES})
439 endif()
440
441 # Add the "-fPIC" option as this static library must be embedded
442 # inside shared libraries (important on UNIX)
443 set_property(
444 TARGET ThirdPartyPlugins
445 PROPERTY POSITION_INDEPENDENT_CODE ON
446 )
447 endif()
448
449
450 #####################################################################
451 ## Build the "ServeFolders" plugin
452 #####################################################################
453
454 if (ENABLE_PLUGINS AND BUILD_SERVE_FOLDERS)
455 if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
456 execute_process(
457 COMMAND
458 ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/../OrthancFramework/Resources/WindowsResources.py
459 ${ORTHANC_VERSION} ServeFolders ServeFolders.dll "Orthanc plugin to serve additional folders"
460 ERROR_VARIABLE Failure
461 OUTPUT_FILE ${AUTOGENERATED_DIR}/ServeFolders.rc
462 )
463
464 if (Failure)
465 message(FATAL_ERROR "Error while computing the version information: ${Failure}")
466 endif()
467
468 list(APPEND SERVE_FOLDERS_RESOURCES ${AUTOGENERATED_DIR}/ServeFolders.rc)
469 endif()
470
471 add_library(ServeFolders SHARED
472 ${CMAKE_SOURCE_DIR}/Plugins/Samples/ServeFolders/Plugin.cpp
473 ${SERVE_FOLDERS_RESOURCES}
474 )
475
476 target_link_libraries(ServeFolders ThirdPartyPlugins)
477
478 set_target_properties(
479 ServeFolders PROPERTIES
480 VERSION ${ORTHANC_VERSION}
481 SOVERSION ${ORTHANC_VERSION}
482 )
483
484 install(
485 TARGETS ServeFolders
486 RUNTIME DESTINATION lib # Destination for Windows
487 LIBRARY DESTINATION share/orthanc/plugins # Destination for Linux
488 )
489 endif()
490
491
492
493 #####################################################################
494 ## Build the "ModalityWorklists" plugin
495 #####################################################################
496
497 if (ENABLE_PLUGINS AND BUILD_MODALITY_WORKLISTS)
498 if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
499 execute_process(
500 COMMAND
501 ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/../OrthancFramework/Resources/WindowsResources.py
502 ${ORTHANC_VERSION} ModalityWorklists ModalityWorklists.dll "Sample Orthanc plugin to serve modality worklists"
503 ERROR_VARIABLE Failure
504 OUTPUT_FILE ${AUTOGENERATED_DIR}/ModalityWorklists.rc
505 )
506
507 if (Failure)
508 message(FATAL_ERROR "Error while computing the version information: ${Failure}")
509 endif()
510
511 list(APPEND MODALITY_WORKLISTS_RESOURCES ${AUTOGENERATED_DIR}/ModalityWorklists.rc)
512 endif()
513
514 add_library(ModalityWorklists SHARED
515 ${CMAKE_SOURCE_DIR}/Plugins/Samples/ModalityWorklists/Plugin.cpp
516 ${MODALITY_WORKLISTS_RESOURCES}
517 )
518
519 target_link_libraries(ModalityWorklists ThirdPartyPlugins)
520
521 set_target_properties(
522 ModalityWorklists PROPERTIES
523 VERSION ${ORTHANC_VERSION}
524 SOVERSION ${ORTHANC_VERSION}
525 )
526
527 install(
528 TARGETS ModalityWorklists
529 RUNTIME DESTINATION lib # Destination for Windows
530 LIBRARY DESTINATION share/orthanc/plugins # Destination for Linux
531 )
532 endif()
533
534
535
536 #####################################################################
537 ## Build the "ConnectivityChecks" plugin
538 #####################################################################
539
540 if (ENABLE_PLUGINS AND BUILD_CONNECTIVITY_CHECKS)
541 include(ExternalProject)
542
543 set(Flags)
544
545 if (CMAKE_TOOLCHAIN_FILE)
546 # Take absolute path to the toolchain
547 get_filename_component(TMP ${CMAKE_TOOLCHAIN_FILE} REALPATH BASE ${CMAKE_SOURCE_DIR})
548 list(APPEND Flags -DCMAKE_TOOLCHAIN_FILE=${TMP})
549 endif()
550
551 if ("${CMAKE_SYSTEM_VERSION}" STREQUAL "LinuxStandardBase")
552 list(APPEND Flags
553 -DLSB_CC=${CMAKE_LSB_CC}
554 -DLSB_CXX=${CMAKE_LSB_CXX}
555 )
556 endif()
557
558 externalproject_add(ConnectivityChecks
559 SOURCE_DIR "${CMAKE_SOURCE_DIR}/Plugins/Samples/ConnectivityChecks"
560
561 # We explicitly provide a build directory, in order to avoid paths
562 # that are too long on our Visual Studio 2008 CIS
563 BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/ConnectivityChecks-build"
564
565 CMAKE_ARGS
566 -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
567 -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}
568 -DPLUGIN_VERSION=${ORTHANC_VERSION}
569 -DSTATIC_BUILD=${STATIC_BUILD}
570 -DALLOW_DOWNLOADS=${ALLOW_DOWNLOADS}
571 -DUSE_SYSTEM_BOOST=${USE_SYSTEM_BOOST}
572 -DUSE_LEGACY_JSONCPP=${USE_LEGACY_JSONCPP}
573 ${Flags}
574 )
575
576 if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
577 if (MSVC)
578 set(Prefix "")
579 else()
580 set(Prefix "lib") # MinGW
581 endif()
582
583 install(FILES
584 ${CMAKE_CURRENT_BINARY_DIR}/${Prefix}ConnectivityChecks.dll
585 DESTINATION "lib")
586 else()
587 list(GET CMAKE_FIND_LIBRARY_PREFIXES 0 Prefix)
588 list(GET CMAKE_FIND_LIBRARY_SUFFIXES 0 Suffix)
589 install(FILES
590 ${CMAKE_CURRENT_BINARY_DIR}/${Prefix}ConnectivityChecks${Suffix}
591 ${CMAKE_CURRENT_BINARY_DIR}/${Prefix}ConnectivityChecks${Suffix}.${ORTHANC_VERSION}
592 DESTINATION "share/orthanc/plugins")
593 endif()
594 endif()
595
596
597
598 #####################################################################
599 ## Build the companion tool to recover files compressed using Orthanc
600 #####################################################################
601
602 if (BUILD_RECOVER_COMPRESSED_FILE)
603 set(RECOVER_COMPRESSED_SOURCES
604 ${CMAKE_SOURCE_DIR}/Resources/Samples/Tools/RecoverCompressedFile.cpp
605 )
606
607 if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
608 execute_process(
609 COMMAND
610 ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/../OrthancFramework/Resources/WindowsResources.py
611 ${ORTHANC_VERSION} OrthancRecoverCompressedFile OrthancRecoverCompressedFile.exe
612 "Lightweight, RESTful DICOM server for medical imaging"
613 ERROR_VARIABLE Failure
614 OUTPUT_FILE ${AUTOGENERATED_DIR}/OrthancRecoverCompressedFile.rc
615 )
616
617 if (Failure)
618 message(FATAL_ERROR "Error while computing the version information: ${Failure}")
619 endif()
620
621 list(APPEND RECOVER_COMPRESSED_SOURCES
622 ${AUTOGENERATED_DIR}/OrthancRecoverCompressedFile.rc
623 )
624 endif()
625
626 add_executable(OrthancRecoverCompressedFile ${RECOVER_COMPRESSED_SOURCES})
627
628 target_link_libraries(OrthancRecoverCompressedFile CoreLibrary)
629
630 install(
631 TARGETS OrthancRecoverCompressedFile
632 RUNTIME DESTINATION bin
633 )
634 endif()
635
636
637
638 #####################################################################
639 ## Generate the documentation if Doxygen is present
640 #####################################################################
641
642 find_package(Doxygen)
643 if (DOXYGEN_FOUND)
644 configure_file(
645 ${CMAKE_SOURCE_DIR}/Resources/Orthanc.doxygen
646 ${CMAKE_CURRENT_BINARY_DIR}/Orthanc.doxygen
647 @ONLY)
648
649 configure_file(
650 ${CMAKE_SOURCE_DIR}/Resources/OrthancPlugin.doxygen
651 ${CMAKE_CURRENT_BINARY_DIR}/OrthancPlugin.doxygen
652 @ONLY)
653
654 add_custom_target(doc
655 ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Orthanc.doxygen
656 COMMENT "Generating internal documentation with Doxygen" VERBATIM
657 )
658
659 add_custom_command(TARGET Orthanc
660 POST_BUILD
661 COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/OrthancPlugin.doxygen
662 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
663 COMMENT "Generating plugin documentation with Doxygen" VERBATIM
664 )
665
666 install(
667 DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/OrthancPluginDocumentation/doc/
668 DESTINATION share/doc/orthanc/OrthancPlugin
669 )
670 else()
671 message("Doxygen not found. The documentation will not be built.")
672 endif()
673
674
675
676 #####################################################################
677 ## Install the plugin SDK
678 #####################################################################
679
680 if (ENABLE_PLUGINS)
681 install(
682 FILES
683 ${CMAKE_SOURCE_DIR}/Plugins/Include/orthanc/OrthancCPlugin.h
684 ${CMAKE_SOURCE_DIR}/Plugins/Include/orthanc/OrthancCDatabasePlugin.h
685 DESTINATION include/orthanc
686 )
687 endif()
688
689
690
691 #####################################################################
692 ## Prepare the "uninstall" target
693 ## http://www.cmake.org/Wiki/CMake_FAQ#Can_I_do_.22make_uninstall.22_with_CMake.3F
694 #####################################################################
695
696 configure_file(
697 "${CMAKE_SOURCE_DIR}/../OrthancFramework/Resources/CMake/Uninstall.cmake.in"
698 "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
699 IMMEDIATE @ONLY)
700
701 add_custom_target(uninstall
702 COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)