autocmake/modules/mpi.cmake
2015-07-17 13:49:09 +02:00

35 lines
926 B
CMake

#.rst:
#
# Enables MPI support.
#
# Variables used::
#
# ENABLE_MPI
# MPI_FOUND
#
# Variables modified (provided the corresponding language is enabled)::
#
# CMAKE_Fortran_FLAGS
#
# Example autocmake.cfg entry::
#
# [mpi]
# source: https://github.com/scisoft/autocmake/raw/master/modules/mpi.cmake
# docopt: --mpi Enable MPI parallelization [default: False].
# define: '-DENABLE_MPI=%s' % arguments['--mpi']
option(ENABLE_MPI "Enable MPI parallelization" OFF)
# on Cray configure with -D MPI_FOUND=1
if(ENABLE_MPI AND NOT MPI_FOUND)
find_package(MPI)
if(MPI_FOUND)
if(DEFINED CMAKE_Fortran_COMPILER_ID)
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${MPI_COMPILE_FLAGS}")
endif()
include_directories(${MPI_INCLUDE_PATH})
else()
message(FATAL_ERROR "-- You asked for MPI, but CMake could not find any MPI installation, check $PATH")
endif()
endif()