diff OrthancServer/CMakeLists.txt @ 4961:1b76853e1797 more-tags

DbOptimizer plugin
author Alain Mazy <am@osimis.io>
date Wed, 23 Mar 2022 11:56:28 +0100
parents 6eff25f70121
children d68b3a2cea17
line wrap: on
line diff
--- a/OrthancServer/CMakeLists.txt	Wed Mar 23 11:52:19 2022 +0100
+++ b/OrthancServer/CMakeLists.txt	Wed Mar 23 11:56:28 2022 +0100
@@ -59,6 +59,7 @@
 SET(BUILD_RECOVER_COMPRESSED_FILE ON CACHE BOOL "Whether to build the companion tool to recover files compressed using Orthanc")
 SET(BUILD_SERVE_FOLDERS ON CACHE BOOL "Whether to build the ServeFolders plugin")
 SET(BUILD_CONNECTIVITY_CHECKS ON CACHE BOOL "Whether to build the ConnectivityChecks plugin")
+SET(BUILD_DB_OPTIMIZER ON CACHE BOOL "Whether to build the DbOptimizer 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")
 
@@ -315,6 +316,7 @@
   -DHAS_ORTHANC_EXCEPTION=0
   -DMODALITY_WORKLISTS_VERSION="${ORTHANC_VERSION}"
   -DSERVE_FOLDERS_VERSION="${ORTHANC_VERSION}"
+  -DDB_OPTIMIZER_VERSION="${ORTHANC_VERSION}"
   )
 
 
@@ -427,7 +429,7 @@
 #####################################################################
 
 if (ENABLE_PLUGINS AND
-    (BUILD_SERVE_FOLDERS OR BUILD_MODALITY_WORKLISTS))
+    (BUILD_SERVE_FOLDERS OR BUILD_MODALITY_WORKLISTS OR BUILD_DB_OPTIMIZER))
   add_library(ThirdPartyPlugins STATIC
     ${BOOST_SOURCES}
     ${JSONCPP_SOURCES}
@@ -598,6 +600,50 @@
 
 
 #####################################################################
+## Build the "DbOptimizer" plugin
+#####################################################################
+
+if (ENABLE_PLUGINS AND BUILD_DB_OPTIMIZER)
+if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
+execute_process(
+  COMMAND 
+  ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/../OrthancFramework/Resources/WindowsResources.py
+  ${ORTHANC_VERSION} DbOptimizer DbOptimizer.dll "Sample Orthanc plugin to optimizer/clean the DB/Storage"
+  ERROR_VARIABLE Failure
+  OUTPUT_FILE ${AUTOGENERATED_DIR}/DbOptimizer.rc
+  )
+
+if (Failure)
+  message(FATAL_ERROR "Error while computing the version information: ${Failure}")
+endif()
+
+list(APPEND DB_OPTIMIZER_RESOURCES ${AUTOGENERATED_DIR}/DbOptimizer.rc)
+endif()
+
+add_library(DbOptimizer SHARED 
+${CMAKE_SOURCE_DIR}/Plugins/Samples/DbOptimizer/Plugin.cpp
+${DB_OPTIMIZER_RESOURCES}
+)
+
+target_link_libraries(DbOptimizer 
+  ThirdPartyPlugins
+  )
+
+set_target_properties(
+  DbOptimizer PROPERTIES 
+VERSION ${ORTHANC_VERSION} 
+SOVERSION ${ORTHANC_VERSION}
+)
+
+install(
+TARGETS DbOptimizer
+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
 #####################################################################