comparison OrthancServer/CMakeLists.txt @ 4091:19a2f1d2b816 framework

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