diff --git a/CMakeFilters.cmake b/CMakeFilters.cmake index 3eca6e743c8..3f9b4cc367b 100644 --- a/CMakeFilters.cmake +++ b/CMakeFilters.cmake @@ -160,15 +160,28 @@ 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 QUIET) if (NOT SZIP_FOUND) - find_package (SZIP) # Legacy find + find_package (SZIP NAMES ${LIBAEC_PACKAGE_NAME}${HDF_PACKAGE_EXT} COMPONENTS ${LIBAEC_SEACH_TYPE}) + 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}) + set (SZIP_TARGET "szip-${LIBAEC_SEACH_TYPE}") + if (TARGET libaec::sz) + set (SZIP_TARGET libaec::sz) + endif () + if (TARGET ${SZIP_TARGET}) + get_target_property (libname ${SZIP_TARGET} LOCATION) + get_filename_component (libname ${libname} NAME_WE) + string (REGEX REPLACE "^lib" "" libname ${libname}) + set_target_properties (${SZIP_TARGET} PROPERTIES OUTPUT_NAME ${libname}) + set (LINK_COMP_LIBS ${LINK_COMP_LIBS} ${SZIP_TARGET}) + endif () endif () else () if (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "GIT" OR HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "TGZ")