--- a/CMakeFilters.cmake
+++ b/CMakeFilters.cmake
@@ -161,10 +161,10 @@
         endif ()
         set (H5_ZLIB_INCLUDE_DIR_GEN ${ZLIB_INCLUDE_DIR})
         set (H5_ZLIB_INCLUDE_DIRS ${H5_ZLIB_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIR})
-        if (NOT WIN32) #windows has a list of names
+        if (NOT MSVC) #windows has a list of names
           # The FindZLIB.cmake module does not set an OUTPUT_NAME
           # on the target. The target returned is: ZLIB::ZLIB
-          get_filename_component (libname ${ZLIB_LIBRARIES} NAME_WLE)
+          get_filename_component (libname ${ZLIB_LIBRARIES} NAME_WE)
           string (REGEX REPLACE "^lib" "" libname ${libname})
           set_target_properties (ZLIB::ZLIB PROPERTIES OUTPUT_NAME ${libname})
         endif ()
@@ -226,6 +226,11 @@
       set (H5_SZIP_INCLUDE_DIRS ${H5_SZIP_INCLUDE_DIRS} ${SZIP_INCLUDE_DIR})
       if (LIBAEC_PACKAGE_NAME STREQUAL "libaec")
         set (LINK_COMP_LIBS ${LINK_COMP_LIBS} libaec::sz libaec::aec)
+        # The targets do not set an OUTPUT_NAME on the target.
+        get_filename_component (libname ${SZIP_LIBRARIES} NAME_WE)
+        string (REGEX REPLACE "^lib" "" libname ${libname})
+        set_target_properties (libaec::sz PROPERTIES OUTPUT_NAME ${libname})
+        set_target_properties (libaec::aec PROPERTIES OUTPUT_NAME aec)
       else ()
         set (LINK_COMP_LIBS ${LINK_COMP_LIBS} ${SZIP_LIBRARIES})
       endif ()
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1453,7 +1453,12 @@
 # The settings for the compression libs depends on if they have pkconfig support
 # Assuming they don't
 foreach (libs ${LINK_COMP_LIBS})
-  get_target_property (libname ${libs} OUTPUT_NAME)
+  if(TARGET ${libs})
+    get_target_property (libname ${libs} OUTPUT_NAME)
+  else()
+    get_filename_component(libname ${libs} NAME_WE )
+    string(REGEX REPLACE "^lib" "" libname ${libname} )
+  endif()
   set (_PKG_CONFIG_LIBS_PRIVATE "${_PKG_CONFIG_LIBS_PRIVATE} -l${libname}")
 endforeach ()
 
