Skip to content

Commit

Permalink
Trying to fix macos build
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidAce committed Jan 22, 2025
1 parent db9e02e commit 1bd60e8
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,9 @@
"Linux",
"Darwin"
]
},
"environment": {
"CMAKE_FRAMEWORK_PATH": "/opt/homebrew"
}
},
{
Expand Down
29 changes: 28 additions & 1 deletion cmake/HDF5TargetUtils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ function(h5pp_get_modern_hdf5_target_name)
get_target_property(HDF5_LINK_LIBS HDF5::HDF5 INTERFACE_LINK_LIBRARIES)
foreach(tgt ${HDF5_X_TARGETS};${HDF5_C_TARGET})
if(NOT ${tgt} IN_LIST HDF5_LINK_LIBS)
message(STATUS "LINKING HDF5::HDF5 INTERFACE ${tgt}")
message(DEBUG "LINKING HDF5::HDF5 INTERFACE ${tgt}")
target_link_libraries(HDF5::HDF5 INTERFACE ${tgt})
endif()
endforeach()
Expand All @@ -159,4 +159,31 @@ function(h5pp_get_modern_hdf5_target_name)
else()
message(FATAL_ERROR "Failed to define a standard HDF5::HDF5: Could not find any known HDF5 targets or variable HDF5_LIBRARIES")
endif()


# Check whether zlib or szip are linked to the targets, and make sure we can find them
foreach (tgt ${HDF5_X_TARGETS};${HDF5_C_TARGET})
message(STATUS " ${lib}")
get_target_property(HDF5_INTERFACE_LINK_LIBRARIES ${tgt} INTERFACE_LINK_LIBRARIES)
mark_as_advanced(HDF5_INTERFACE_LINK_LIBRARIES)
foreach (ltgt ${HDF5_INTERFACE_LINK_LIBRARIES})
message(STATUS " ${ltgt}")
if(ltgt STREQUAL "ZLIB::ZLIB")
set(HDF5_ZLIB_REQUIRED REQUIRED)
endif()
if(ltgt STREQUAL "z")
set(HDF5_z_REQUIRED REQUIRED)
endif()
if(ltgt STREQUAL "SZIP::SZIP")
set(HDF5_SZIP_REQUIRED REQUIRED)
endif()
if(ltgt STREQUAL "sz")
set(HDF5_sz_REQUIRED REQUIRED)
endif()
endforeach()
endforeach ()
find_package(ZLIB ${HDF5_ZLIB_REQUIRED} QUIET)
find_package(SZIP ${HDF5_SZIP_REQUIRED} QUIET)
find_library(LIBRARY_Z z ${HDF5_z_REQUIRED} QUIET)
find_library(LIBRARY_SZ sz ${HDF5_sz_REQUIRED} QUIET)
endfunction()
1 change: 1 addition & 0 deletions cmake/SetupDependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,4 @@ if(TARGET SZIP::SZIP)
endif()
target_link_libraries(deps INTERFACE HDF5::HDF5)


0 comments on commit 1bd60e8

Please sign in to comment.