diff --git a/CMakeLists.txt b/CMakeLists.txt index abadd5ea..3144480b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -369,24 +369,27 @@ if(MPI_FOUND) file(MAKE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}) set(_mpi_mod_found FALSE) - foreach(_mod_name mpi.mod MPI.mod) - foreach(_inc ${_mpi_fortran_inc}) - if(EXISTS "${_inc}/${_mod_name}") - file(COPY "${_inc}/${_mod_name}" DESTINATION "${CMAKE_Fortran_MODULE_DIRECTORY}") - message(STATUS "Copied ${_mod_name} from ${_inc}") - set(_mpi_mod_found TRUE) + if(_mpi_fortran_inc) + foreach(_mod_name mpi.mod MPI.mod) + foreach(_inc ${_mpi_fortran_inc}) + if(EXISTS "${_inc}/${_mod_name}") + file(COPY "${_inc}/${_mod_name}" DESTINATION "${CMAKE_Fortran_MODULE_DIRECTORY}") + message(STATUS "Copied ${_mod_name} from ${_inc}") + set(_mpi_mod_found TRUE) + break() + endif() + endforeach() + if(_mpi_mod_found) break() endif() endforeach() - if(_mpi_mod_found) - break() - endif() - endforeach() + endif() if(NOT _mpi_mod_found) - message(WARNING "mpi.mod not found in MPI include paths; assuming mpifort provides it internally.") + message(WARNING "mpi.mod not found in MPI include paths; assuming mpifort provides it internally. Skipping copy.") endif() + # ------------------------------------------------------------ # Enable MPI Fortran module support # ------------------------------------------------------------