Skip to content

Commit

Permalink
hdf5: support HDF5_PREFER_PARELLEL cmake option
Browse files Browse the repository at this point in the history
  • Loading branch information
Kumataro committed Dec 28, 2024
1 parent 3e776c8 commit 7fda317
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
18 changes: 15 additions & 3 deletions modules/hdf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,23 @@ if(NOT HDF5_FOUND)
ocv_module_disable(hdf) # no return
endif()

set(HAVE_HDF5 1)
# See https://github.com/opencv/opencv_contrib/issues/3858
# If HDF5_PREFER_PARALLEL is enabled, find_package(HDF5) sets HDF5_IS_PARALLEL=ON.
if(HDF5_IS_PARALLEL)
find_package(MPI)
if(NOT MPI_FOUND)
message(STATUS "Module opencv_hdf disabled because the following dependency is not found: MPI")
ocv_module_disable(hdf) # no return
endif()
else()
unset(MPI_CXX_LIBRARIES)
unset(MPI_CXX_INCLUDE_DIRS)
endif()

set(HAVE_HDF5 1)
ocv_warnings_disable(CMAKE_CXX_FLAGS -Winvalid-offsetof)

set(the_description "Hierarchical Data Format I/O")
ocv_define_module(hdf opencv_core WRAP python)
ocv_target_link_libraries(${the_module} ${HDF5_LIBRARIES})
ocv_include_directories(${HDF5_INCLUDE_DIRS})
ocv_target_link_libraries(${the_module} ${HDF5_LIBRARIES} ${MPI_CXX_LIBRARIES})
ocv_include_directories(${HDF5_INCLUDE_DIRS} ${MPI_CXX_INCLUDE_DIRS})
4 changes: 4 additions & 0 deletions modules/hdf/include/opencv2/hdf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ This module provides storage routines for Hierarchical Data Format objects.
In order to use it, the hdf5 library has to be installed, which
means cmake should find it using `find_package(HDF5)`.
You can use parallel hdf5 library with `-DHDF5_PREFER_PARELLEL=ON` cmake option.
Depended MPI library(e.g. Open MPI or MPICH) is detected in `find_package(MPI)`.
To set prefer MPI library, `update-alternatives` command is helpful for your Ubuntu.
@}
*/

Expand Down

0 comments on commit 7fda317

Please sign in to comment.