diff --git a/lib/spack/spack/build_systems/cached_cmake.py b/lib/spack/spack/build_systems/cached_cmake.py index c22068e5ca354b..273eb070b10637 100644 --- a/lib/spack/spack/build_systems/cached_cmake.py +++ b/lib/spack/spack/build_systems/cached_cmake.py @@ -192,7 +192,10 @@ def initconfig_mpi_entries(self): entries.append(cmake_cache_path("MPI_C_COMPILER", spec["mpi"].mpicc)) entries.append(cmake_cache_path("MPI_CXX_COMPILER", spec["mpi"].mpicxx)) - entries.append(cmake_cache_path("MPI_Fortran_COMPILER", spec["mpi"].mpifc)) + + # not all MPIs have Fortran wrappers + if hasattr(spec["mpi"], "mpifc"): + entries.append(cmake_cache_path("MPI_Fortran_COMPILER", spec["mpi"].mpifc)) # Check for slurm using_slurm = False diff --git a/var/spack/repos/builtin/packages/mpich/package.py b/var/spack/repos/builtin/packages/mpich/package.py index f97ce4f545173f..a1816d401af7d1 100644 --- a/var/spack/repos/builtin/packages/mpich/package.py +++ b/var/spack/repos/builtin/packages/mpich/package.py @@ -60,7 +60,7 @@ class Mpich(AutotoolsPackage, CudaPackage, ROCmPackage): depends_on("c", type="build") # generated depends_on("cxx", type="build") # generated - depends_on("fortran", type="build") # generated + depends_on("fortran", type="build", when="+fortran") variant("hwloc", default=True, description="Use external hwloc package") variant("hydra", default=True, description="Build the hydra process manager")