cmake: pick zstd and zlib-ng targets per BUILD_SHARED_LIBS

Both packages export separate static and shared imported targets, but
the find_package paths picked one variant unconditionally — zstd
preferred libzstd_static and zlib-ng always linked the shared zlib.
Building minizip-ng with BUILD_SHARED_LIBS=ON against a system zstd
that ships both variants therefore produced a libminizip.so with zstd
statically baked in (#983).
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 93e7bb3..526af2d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -203,7 +203,11 @@
     if(ZLIB-NG_FOUND AND NOT MZ_FORCE_FETCH_LIBS)
         message(STATUS "Using ZLIB-NG")
 
-        list(APPEND MINIZIP_LIB_PUBLIC zlib-ng::zlib)
+        if(BUILD_SHARED_LIBS)
+            list(APPEND MINIZIP_LIB_PUBLIC zlib-ng::zlib)
+        else()
+            list(APPEND MINIZIP_LIB_PUBLIC zlib-ng::zlibstatic)
+        endif()
 
         set(PC_PRIVATE_DEPS "zlib-ng")
         set(ZLIB_COMPAT OFF)
@@ -401,10 +405,10 @@
     if(zstd_FOUND AND NOT MZ_FORCE_FETCH_LIBS)
         message(STATUS "Using ZSTD ${zstd_VERSION}")
 
-        if(TARGET zstd::libzstd_static)
-            list(APPEND MINIZIP_LIB zstd::libzstd_static)
-        else()
+        if(BUILD_SHARED_LIBS)
             list(APPEND MINIZIP_LIB zstd::libzstd_shared)
+        else()
+            list(APPEND MINIZIP_LIB zstd::libzstd_static)
         endif()
 
         set(PC_PRIVATE_LIBS "${PC_PRIVATE_LIBS} -lzstd")