Skip to content

Commit

Permalink
Fix CMake build detection of libaec
Browse files Browse the repository at this point in the history
Partial revert of #4567 as libaec
is the correct name of latest package and should be searched first.
Otherwise, it is not found even if `LIBAEC_PACKAGE_NAME=libaec`.

Also fixes pkg-config generation handling. This does mean the output
CMake configuration files need to `find_package(libaec)` prior to
`hdf5-static`, but it also avoids using absolute path to shared library
so that users can do `set(libaec_USE_STATIC_LIBS ON)`.

Also fix build with original SZIP without vcpkg patch.
  • Loading branch information
cho-m committed Oct 25, 2024
1 parent ee61dd5 commit 8089a2d
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions CMakeFilters.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 8089a2d

Please sign in to comment.