diff OrthancServer/CMakeLists.txt @ 5273:7cb1b851f5c8

Added a sample plugin bringing multitenant DICOM support through labels
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 14 Apr 2023 11:49:24 +0200
parents cdeb7f027c1b
children fddb5d8d0021
line wrap: on
line diff
--- a/OrthancServer/CMakeLists.txt	Thu Apr 13 21:17:55 2023 +0200
+++ b/OrthancServer/CMakeLists.txt	Fri Apr 14 11:49:24 2023 +0200
@@ -61,6 +61,7 @@
 SET(BUILD_CONNECTIVITY_CHECKS ON CACHE BOOL "Whether to build the ConnectivityChecks plugin")
 SET(BUILD_HOUSEKEEPER ON CACHE BOOL "Whether to build the Housekeeper plugin")
 SET(BUILD_DELAYED_DELETION ON CACHE BOOL "Whether to build the DelayedDeletion plugin")
+SET(BUILD_MULTITENANT_DICOM ON CACHE BOOL "Whether to build the MultitenantDicom plugin")
 SET(ENABLE_PLUGINS ON CACHE BOOL "Enable plugins")
 SET(UNIT_TESTS_WITH_HTTP_CONNEXIONS ON CACHE BOOL "Allow unit tests to make HTTP requests")
 
@@ -466,12 +467,12 @@
 
 
 #####################################################################
-## Build a static library to share code between the plugins
+## Static library to share third-party libraries between the plugins
 #####################################################################
 
 if (ENABLE_PLUGINS AND
     (BUILD_SERVE_FOLDERS OR BUILD_MODALITY_WORKLISTS OR BUILD_HOUSEKEEPER OR
-      BUILD_DELAYED_DELETION))
+      BUILD_DELAYED_DELETION OR BUILD_MULTITENANT_DICOM))
   set(PLUGINS_DEPENDENCIES_SOURCES
     ${BOOST_SOURCES}
     ${JSONCPP_SOURCES}
@@ -488,8 +489,16 @@
 
   if (BUILD_DELAYED_DELETION)
     list(APPEND PLUGINS_DEPENDENCIES_SOURCES
+      ${SQLITE_SOURCES}
+      )
+  endif()
+  
+  if (BUILD_MULTITENANT_DICOM)
+    list(APPEND PLUGINS_DEPENDENCIES_SOURCES
       ${DCMTK_SOURCES}
-      ${SQLITE_SOURCES}
+      ${OPENSSL_SOURCES}
+      ${LIBJPEG_SOURCES}
+      ${LIBPNG_SOURCES}
       )
   endif()
   
@@ -642,6 +651,7 @@
   add_library(ConnectivityChecks SHARED 
     ${AUTOGENERATED_DIR}/ConnectivityChecksResources.cpp
     ${CMAKE_SOURCE_DIR}/Plugins/Samples/ConnectivityChecks/Plugin.cpp
+    
     ${CMAKE_SOURCE_DIR}/Plugins/Samples/ConnectivityChecks/OrthancFrameworkDependencies.cpp
     ${CONNECTIVITY_CHECKS_RESOURCES}
     )
@@ -693,11 +703,12 @@
   add_library(DelayedDeletion SHARED 
     ${CMAKE_SOURCE_DIR}/Plugins/Samples/DelayedDeletion/PendingDeletionsDatabase.cpp
     ${CMAKE_SOURCE_DIR}/Plugins/Samples/DelayedDeletion/Plugin.cpp
+    
     ${CMAKE_SOURCE_DIR}/Plugins/Samples/DelayedDeletion/OrthancFrameworkDependencies.cpp
     ${DELAYED_DELETION_RESOURCES}
     )
   
-  target_link_libraries(DelayedDeletion PluginsDependencies ${DCMTK_LIBRARIES})
+  target_link_libraries(DelayedDeletion PluginsDependencies)
   
   set_target_properties(
     DelayedDeletion PROPERTIES
@@ -761,6 +772,71 @@
 
 
 #####################################################################
+## Build the "MultitenantDicom" plugin
+#####################################################################
+
+if (ENABLE_PLUGINS AND BUILD_MULTITENANT_DICOM)
+  if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
+    execute_process(
+      COMMAND 
+      ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/../OrthancFramework/Resources/WindowsResources.py
+      ${ORTHANC_VERSION} MultitenantDicom MultitenantDicom.dll "Orthanc plugin to provide a multitenant DICOM server"
+      ERROR_VARIABLE Failure
+      OUTPUT_FILE ${AUTOGENERATED_DIR}/MultitenantDicom.rc
+      )
+    
+    if (Failure)
+      message(FATAL_ERROR "Error while computing the version information: ${Failure}")
+    endif()
+    
+    list(APPEND MULTITENANT_DICOM_RESOURCES ${AUTOGENERATED_DIR}/MultitenantDicom.rc)
+  endif()
+
+  EmbedResources(
+    --target=MultitenantDicomResources
+    --namespace=Orthanc.FrameworkResources
+    --framework-path=${CMAKE_SOURCE_DIR}/../OrthancFramework/Sources
+    ${DCMTK_DICTIONARIES}
+    )
+
+  set_source_files_properties(
+    ${CMAKE_SOURCE_DIR}/Plugins/Samples/MultitenantDicom/Plugin.cpp
+    PROPERTIES COMPILE_DEFINITIONS "ORTHANC_PLUGIN_VERSION=\"${ORTHANC_VERSION}\""
+    )
+
+  # The "OrthancFrameworkDependencies.cpp" file is used to bypass the
+  # precompiled headers if compiling with Visual Studio
+  add_library(MultitenantDicom SHARED 
+    ${CMAKE_SOURCE_DIR}/Plugins/Samples/MultitenantDicom/DicomFilter.cpp
+    ${CMAKE_SOURCE_DIR}/Plugins/Samples/MultitenantDicom/FindRequestHandler.cpp
+    ${CMAKE_SOURCE_DIR}/Plugins/Samples/MultitenantDicom/MoveRequestHandler.cpp
+    ${CMAKE_SOURCE_DIR}/Plugins/Samples/MultitenantDicom/MultitenantDicomServer.cpp
+    ${CMAKE_SOURCE_DIR}/Plugins/Samples/MultitenantDicom/Plugin.cpp
+    ${CMAKE_SOURCE_DIR}/Plugins/Samples/MultitenantDicom/PluginToolbox.cpp
+    ${CMAKE_SOURCE_DIR}/Plugins/Samples/MultitenantDicom/StoreRequestHandler.cpp    
+
+    ${CMAKE_SOURCE_DIR}/Plugins/Samples/MultitenantDicom/OrthancFrameworkDependencies.cpp
+    ${AUTOGENERATED_DIR}/MultitenantDicomResources.cpp
+    ${MULTITENANT_DICOM_RESOURCES}
+    )
+  
+  target_link_libraries(MultitenantDicom PluginsDependencies ${DCMTK_LIBRARIES})
+  
+  set_target_properties(
+    MultitenantDicom PROPERTIES
+    VERSION ${ORTHANC_VERSION}
+    SOVERSION ${ORTHANC_VERSION}
+    )
+  
+  install(
+    TARGETS MultitenantDicom
+    RUNTIME DESTINATION lib    # Destination for Windows
+    LIBRARY DESTINATION share/orthanc/plugins    # Destination for Linux
+    )
+endif()
+
+
+#####################################################################
 ## Build the companion tool to recover files compressed using Orthanc
 #####################################################################