diff --git a/CMakeFilters.cmake b/CMakeFilters.cmake index 3eca6e743c8..255b72be122 100644 --- a/CMakeFilters.cmake +++ b/CMakeFilters.cmake @@ -160,15 +160,27 @@ if (HDF5_ENABLE_SZIP_SUPPORT) endif () set(libaec_USE_STATIC_LIBS ${HDF5_USE_LIBAEC_STATIC}) set(SZIP_FOUND FALSE) - find_package (SZIP NAMES ${LIBAEC_PACKAGE_NAME}${HDF_PACKAGE_EXT} COMPONENTS ${LIBAEC_SEACH_TYPE}) + find_package (libaec CONFIG) if (NOT SZIP_FOUND) - find_package (SZIP) # Legacy find + find_package (SZIP NAMES ${LIBAEC_PACKAGE_NAME}${HDF_PACKAGE_EXT} COMPONENTS ${LIBAEC_SEACH_TYPE}) # Legacy find + if (NOT SZIP_FOUND) + find_package (SZIP) # Legacy find + endif () endif () set(H5_SZIP_FOUND ${SZIP_FOUND}) if (H5_SZIP_FOUND) set (H5_SZIP_INCLUDE_DIR_GEN ${SZIP_INCLUDE_DIR}) set (H5_SZIP_INCLUDE_DIRS ${H5_SZIP_INCLUDE_DIRS} ${SZIP_INCLUDE_DIR}) - set (LINK_COMP_LIBS ${LINK_COMP_LIBS} ${SZIP_LIBRARIES}) + if (TARGET libaec::sz) + # The libaec-config.cmake does not set an OUTPUT_NAME + # on the target. The target returned is: libaec::sz + get_filename_component (libname ${SZIP_LIBRARIES} NAME_WLE) + string (REGEX REPLACE "^lib" "" libname ${libname}) + set_target_properties (libaec::sz PROPERTIES OUTPUT_NAME ${libname}) + set (LINK_COMP_LIBS ${LINK_COMP_LIBS} libaec::sz) + else () + set (LINK_COMP_LIBS ${LINK_COMP_LIBS} ${SZIP_LIBRARIES}) + endif () endif () else () if (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "GIT" OR HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "TGZ")