Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not use parallel target in CMake in pure C++ project #3844

Open
cmacmackin opened this issue Nov 13, 2023 · 1 comment
Open

Can not use parallel target in CMake in pure C++ project #3844

cmacmackin opened this issue Nov 13, 2023 · 1 comment
Assignees
Labels
Component - Build CMake, Autotools Priority - 1. High 🔼 These are important issues that should be resolved in the next release Type - Bug / Bugfix Please report security issues to help@hdfgroup.org instead of creating an issue on GitHub

Comments

@cmacmackin
Copy link

cmacmackin commented Nov 13, 2023

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:

CMake Error at /home/cmacmack/.spack/opt/spack/linux-linuxmint21-icelake/gcc-11.3.0/hdf5-1.14.1-2-nabfxjrrsno6gmfw5fsnot4b5geztyd3/cmake/hdf5-targets.cmake:68 (set_target_properties):
  The link interface of target "hdf5-shared" contains:

    MPI::MPI_C

  but the target was not found.  Possible reasons include:

    * There is a typo in the target name.
    * A find_package call is missing for an IMPORTED target.
    * An ALIAS target is missing.

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)

  • HDF5 1.14.1-2
  • Linux Mint 21.1 (which is based on Ubuntu 22.04)
  • GCC 11.3.0
  • CMake 3.24.3
  • set(HDF5_PREFER_PARALLEL TRUE)
  • MPICH 4.1.1

HDF5 and its dependencies were compiled using Spack v0.20.3.

@derobins derobins added Merge - To 1.14 Priority - 1. High 🔼 These are important issues that should be resolved in the next release Component - Build CMake, Autotools Type - Bug / Bugfix Please report security issues to help@hdfgroup.org instead of creating an issue on GitHub labels Nov 13, 2023
@mirenradia
Copy link

mirenradia commented Mar 19, 2024

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 1.14.3
  • RHEL 8.8
  • Nvidia Fortran Compiler (nvfortran) 24.3
  • CMake 3.27.9
  • OpenMPI 4.1.6

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component - Build CMake, Autotools Priority - 1. High 🔼 These are important issues that should be resolved in the next release Type - Bug / Bugfix Please report security issues to help@hdfgroup.org instead of creating an issue on GitHub
Projects
None yet
Development

No branches or pull requests

4 participants