Skip to content

HDF5 not found if using hdf5-config.cmake #877

@jsharpe

Description

@jsharpe

# HDF5_C_LIBRARIES may be defined. We must check for either.

In this case only HDF5_hdf5_LIBRARY_RELEASE/HDF5_hdf5_LIBRARY_DEBUG is set.

Also the logic to detect if HDF5 was built in parallel is incorrect. In the case of using the config file this information is available via the variable HDF5_IS_PARALLEL. In the case that the library is named in the variable HDF5_hdf5_LIBRARY.

The correct fix now that the minimum cmake version has been bumped is to simply do find_package(hdf5 REQUIRED) and then link against the meta target hdf5::hdf5-shared or hdf5::hdf5-static as appropriate. This then sets up all the transitive link dependencies and propagates the correct defines for H5_BUILD_AS_DYNAMIC_LIB based upon the options the library was built with.

See the talk at C++Now available here: https://www.youtube.com/watch?v=bsXLMQ6WgIk for more details on this modern style of CMake usage.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions