Open cmacmackin opened 10 months ago
I have the same problem in a pure Fortran project where Fortran is the only enabled language. I'm doing
set(HDF5_PREFER_PARALLEL TRUE)
find_package(HDF5 REQUIRED COMPONENTS Fortran)
if (NOT HDF5_IS_PARALLEL)
message(FATAL_ERROR "Parallel HDF5 Required.")
endif ()
and my software versions are as follows
HDF5, CMake, OpenMPI and their dependencies were built with Spack at d5c1e16e43.
Is it possible to get around this without enabling C (which slows down CMake configuration and is otherwise unneeded)? This only seems to be a problem with HDF5 1.14 and I've not had this problem with various build of 1.12 and 1.10.
Describe the bug When trying to link against the parallel HDF5 target in CMake in a C++ project, CMake complains that the MPI_C target is not found:
This is related to but distinct from the bug addressed by #2400. The reason for the error is that the project only enables the C++ language and CMake therefore does not import the MPI_C target. (Presumably there would be a similar issue in Fortran projects.) Adding
enable_language(C)
before importing the HDF5 package fixes the problem.Expected behavior Parallel HDF5 imports the MPI::MPI_C package to satisfy its public dependency.
Platform (please complete the following information)
set(HDF5_PREFER_PARALLEL TRUE)
HDF5 and its dependencies were compiled using Spack v0.20.3.