Skip to content

Commit 9f2529f

Browse files
committed
FindHDF5: if H5_HAVE_FILTER_SZIP defined, check it exists
1 parent 71e6aa0 commit 9f2529f

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

cmake/FindHDF5.cmake

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,8 @@ if(hdf5_have_zlib)
191191
DOC "SZIP header"
192192
)
193193

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

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

912-
target_include_directories(HDF5::HDF5 INTERFACE
913-
$<$<BOOL:${hdf5_have_szip}>:${SZIP_INCLUDE_DIR}>
914-
)
913+
if(hdf5_have_szip)
914+
if(IS_DIRECTORY "${SZIP_INCLUDE_DIR}")
915+
target_include_directories(HDF5::HDF5 INTERFACE ${SZIP_INCLUDE_DIR})
916+
else()
917+
message(STATUS "FindHDF5: SZIP_INCLUDE_DIR ${SZIP_INCLUDE_DIR} is not a directory.")
918+
endif()
919+
endif()
920+
921+
target_link_libraries(HDF5::HDF5 INTERFACE $<$<BOOL:${hdf5_have_zlib}>:ZLIB::ZLIB>)
922+
923+
if(hdf5_have_szip)
924+
if(EXISTS "${SZIP_LIBRARY}")
925+
target_link_libraries(HDF5::HDF5 INTERFACE ${SZIP_LIBRARY})
926+
else()
927+
message(STATUS "FindHDF5: SZIP_LIBRARY ${SZIP_LIBRARY} is not a file.")
928+
endif()
929+
endif()
930+
915931
target_link_libraries(HDF5::HDF5 INTERFACE
916-
$<$<BOOL:${hdf5_have_zlib}>:ZLIB::ZLIB>
917-
$<$<BOOL:${hdf5_have_szip}>:${SZIP_LIBRARY}>
918932
${CMAKE_THREAD_LIBS_INIT}
919933
${CMAKE_DL_LIBS}
920934
$<$<BOOL:${UNIX}>:m>
921935
)
922-
923936
endif()
924937
endif(HDF5_FOUND)
925938

0 commit comments

Comments
 (0)