diff --git a/scripts/cmake/Dependencies.cmake b/scripts/cmake/Dependencies.cmake
index d40025ab2c66271130797e5c3bf8f693c9e9c9b6..63d40dbb52320736449f91b5e19f61f5a39554e0 100644
--- a/scripts/cmake/Dependencies.cmake
+++ b/scripts/cmake/Dependencies.cmake
@@ -205,7 +205,10 @@ else()
     if(HDF5_ADDED)
         target_include_directories(hdf5-static INTERFACE ${HDF5_BINARY_DIR})
         list(APPEND DISABLE_WARNINGS_TARGETS hdf5-static)
-        set(HDF5_LIBRARIES hdf5-static zlibstatic)
+        set(HDF5_LIBRARIES hdf5-static)
+        if(ZLIB_ADDED)
+            list(APPEND HDF5_LIBRARIES zlibstatic)
+        endif()
         set(HDF5_C_INCLUDE_DIR ${HDF5_SOURCE_DIR})
         set(HDF5_INCLUDE_DIR ${HDF5_SOURCE_DIR})
     endif()