Skip to content

Commit

Permalink
FindHDF5: if H5_HAVE_FILTER_SZIP defined, check it exists
Browse files Browse the repository at this point in the history
  • Loading branch information
scivision committed Aug 30, 2024
1 parent 71e6aa0 commit 5071a08
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions cmake/FindHDF5.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ if(hdf5_have_zlib)
)

if(NOT SZIP_LIBRARY AND SZIP_INCLUDE_DIR)
message(VERBOSE "FindHDF5: SZIP not found, but HDF5 indicates it was built with SZIP. This may cause build errors.")
return()
endif()

Expand Down Expand Up @@ -909,17 +910,29 @@ if(HDF5_FOUND)
set_property(TARGET HDF5::HDF5 PROPERTY INTERFACE_LINK_LIBRARIES "${HDF5_LIBRARIES}")
set_property(TARGET HDF5::HDF5 PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${HDF5_INCLUDE_DIRS}")

target_include_directories(HDF5::HDF5 INTERFACE
$<$<BOOL:${hdf5_have_szip}>:${SZIP_INCLUDE_DIR}>
)
if(hdf5_have_szip)
if(IS_DIRECTORY "${SZIP_INCLUDE_DIR}")
target_include_directories(HDF5::HDF5 INTERFACE ${SZIP_INCLUDE_DIR})
else()
message(STATUS "FindHDF5: SZIP_INCLUDE_DIR ${SZIP_INCLUDE_DIR} is not a directory.")
endif()
endif()

target_link_libraries(HDF5::HDF5 INTERFACE $<$<BOOL:${hdf5_have_zlib}>:ZLIB::ZLIB>)

if(hdf5_have_szip)
if(EXISTS "${SZIP_LIBRARY}")
target_link_libraries(HDF5::HDF5 INTERFACE ${SZIP_LIBRARY})
else()
message(STATUS "FindHDF5: SZIP_LIBRARY ${SZIP_LIBRARY} is not a file.")
endif()
endif()

target_link_libraries(HDF5::HDF5 INTERFACE
$<$<BOOL:${hdf5_have_zlib}>:ZLIB::ZLIB>
$<$<BOOL:${hdf5_have_szip}>:${SZIP_LIBRARY}>
${CMAKE_THREAD_LIBS_INIT}
${CMAKE_DL_LIBS}
$<$<BOOL:${UNIX}>:m>
)

endif()
endif(HDF5_FOUND)

Expand Down

0 comments on commit 5071a08

Please sign in to comment.