changeset 6622:91f2ac416601

added cmake option USE_SYSTEM_MINIZIP
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 16 Mar 2026 18:38:07 +0100
parents 7c6c02b669a8
children 241f2169c029
files NEWS OrthancFramework/Resources/CMake/MinizipConfiguration.cmake OrthancFramework/Resources/CMake/OrthancFrameworkConfiguration.cmake OrthancFramework/Resources/CMake/OrthancFrameworkParameters.cmake OrthancFramework/Sources/Compression/ZipReader.cpp OrthancFramework/Sources/Compression/ZipWriter.cpp
diffstat 6 files changed, 77 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Mon Mar 16 14:52:20 2026 +0100
+++ b/NEWS	Mon Mar 16 18:38:07 2026 +0100
@@ -50,6 +50,7 @@
   https://orthanc.uclouvain.be/bugs/show_bug.cgi?id=255
 * Save the jobs registry in DB only if it has changed.
   https://discourse.orthanc-server.org/t/frequent-idle-messages-between-postgres-and-orthanc/6406
+* New CMake option: "USE_SYSTEM_MINIZIP" to use the system-wide version of minizip
 * Upgraded dependencies for static builds:
   - boost 1.89.0
   - dcmtk 3.7.0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/OrthancFramework/Resources/CMake/MinizipConfiguration.cmake	Mon Mar 16 18:38:07 2026 +0100
@@ -0,0 +1,51 @@
+# Orthanc - A Lightweight, RESTful DICOM Store
+# Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
+# Department, University Hospital of Liege, Belgium
+# Copyright (C) 2017-2023 Osimis S.A., Belgium
+# Copyright (C) 2024-2026 Orthanc Team SRL, Belgium
+# Copyright (C) 2021-2026 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
+#
+# This program is free software: you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public License
+# as published by the Free Software Foundation, either version 3 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this program. If not, see
+# <http://www.gnu.org/licenses/>.
+
+
+if (NOT ENABLE_ZLIB OR ORTHANC_SANDBOXED)
+  message(FATAL_ERROR "This file cannot be used if zlib is disabled or if targeting WebAssembly")
+endif()
+
+if (STATIC_BUILD OR NOT USE_SYSTEM_MINIZIP)
+  add_definitions(-DORTHANC_USE_SYSTEM_MINIZIP=0)
+
+  list(APPEND ORTHANC_CORE_SOURCES_DEPENDENCIES
+    ${CMAKE_CURRENT_LIST_DIR}/../../Resources/ThirdParty/minizip/ioapi.c
+    ${CMAKE_CURRENT_LIST_DIR}/../../Resources/ThirdParty/minizip/unzip.c
+    ${CMAKE_CURRENT_LIST_DIR}/../../Resources/ThirdParty/minizip/zip.c
+    )
+
+else()
+  add_definitions(-DORTHANC_USE_SYSTEM_MINIZIP=1)
+
+  CHECK_INCLUDE_FILE_CXX(minizip/zip.h HAVE_MINIZIP_H)
+  if (NOT HAVE_MINIZIP_H)
+    message(FATAL_ERROR "Please install the libminizip-dev package")
+  endif()
+
+  CHECK_LIBRARY_EXISTS(minizip "zipOpen2_64" "" HAVE_MINIZIP_LIB)
+  if (NOT HAVE_MINIZIP_LIB)
+    message(FATAL_ERROR "Please install the libminizip-dev package")
+  endif()
+
+  link_libraries(minizip)
+
+endif()
--- a/OrthancFramework/Resources/CMake/OrthancFrameworkConfiguration.cmake	Mon Mar 16 14:52:20 2026 +0100
+++ b/OrthancFramework/Resources/CMake/OrthancFrameworkConfiguration.cmake	Mon Mar 16 18:38:07 2026 +0100
@@ -753,12 +753,8 @@
   )
 
 if (ENABLE_ZLIB AND NOT ORTHANC_SANDBOXED)
-  list(APPEND ORTHANC_CORE_SOURCES_DEPENDENCIES
-    # This is the minizip distribution to create/decode ZIP files using zlib
-    ${CMAKE_CURRENT_LIST_DIR}/../../Resources/ThirdParty/minizip/ioapi.c
-    ${CMAKE_CURRENT_LIST_DIR}/../../Resources/ThirdParty/minizip/unzip.c
-    ${CMAKE_CURRENT_LIST_DIR}/../../Resources/ThirdParty/minizip/zip.c
-    )
+  # This is the minizip distribution to create/decode ZIP files using zlib
+  include(${CMAKE_CURRENT_LIST_DIR}/MinizipConfiguration.cmake)
 endif()
 
 
--- a/OrthancFramework/Resources/CMake/OrthancFrameworkParameters.cmake	Mon Mar 16 14:52:20 2026 +0100
+++ b/OrthancFramework/Resources/CMake/OrthancFrameworkParameters.cmake	Mon Mar 16 18:38:07 2026 +0100
@@ -69,6 +69,7 @@
 set(USE_SYSTEM_LIBP11 OFF CACHE BOOL "Use the system version of libp11 (PKCS#11 wrapper library)")
 set(USE_SYSTEM_LIBPNG ON CACHE BOOL "Use the system version of libpng")
 set(USE_SYSTEM_LUA ON CACHE BOOL "Use the system version of Lua")
+set(USE_SYSTEM_MINIZIP OFF CACHE BOOL "Use the system version minizip (new in Orthanc 1.12.11)")
 set(USE_SYSTEM_MONGOOSE ON CACHE BOOL "Use the system version of Mongoose")
 set(USE_SYSTEM_OPENSSL ON CACHE BOOL "Use the system version of OpenSSL")
 set(USE_SYSTEM_PROTOBUF ON CACHE BOOL "Use the system version of Google Protocol Buffers")
--- a/OrthancFramework/Sources/Compression/ZipReader.cpp	Mon Mar 16 14:52:20 2026 +0100
+++ b/OrthancFramework/Sources/Compression/ZipReader.cpp	Mon Mar 16 18:38:07 2026 +0100
@@ -28,10 +28,20 @@
 #define NOMINMAX
 #endif
 
+#if !defined(ORTHANC_USE_SYSTEM_MINIZIP)
+#  error The macro ORTHANC_USE_SYSTEM_MINIZIP must be defined
+#endif
+
 #include "ZipReader.h"
 
+#if ORTHANC_USE_SYSTEM_MINIZIP == 1
+#  include <minizip/unzip.h>
+#else
+#  include "../../Resources/ThirdParty/minizip/unzip.h"
+#endif
+
+
 #include "../OrthancException.h"
-#include "../../Resources/ThirdParty/minizip/unzip.h"
 
 #if ORTHANC_SANDBOXED != 1
 #  include "../SystemToolbox.h"
--- a/OrthancFramework/Sources/Compression/ZipWriter.cpp	Mon Mar 16 14:52:20 2026 +0100
+++ b/OrthancFramework/Sources/Compression/ZipWriter.cpp	Mon Mar 16 18:38:07 2026 +0100
@@ -28,13 +28,23 @@
 #define NOMINMAX
 #endif
 
+#if !defined(ORTHANC_USE_SYSTEM_MINIZIP)
+#  error The macro ORTHANC_USE_SYSTEM_MINIZIP must be defined
+#endif
+
 #include "ZipWriter.h"
 
+
 #include <limits>
 #include <boost/filesystem.hpp>
 #include <boost/date_time/posix_time/posix_time.hpp>
 
-#include "../../Resources/ThirdParty/minizip/zip.h"
+#if ORTHANC_USE_SYSTEM_MINIZIP == 1
+#  include <minizip/zip.h>
+#else
+#  include "../../Resources/ThirdParty/minizip/zip.h"
+#endif
+
 #include "../Logging.h"
 #include "../OrthancException.h"
 #include "../SystemToolbox.h"