1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
|
## ---------------------------------------------------------------------
##
## Copyright (C) 2012 - 2018 by the deal.II authors
##
## This file is part of the deal.II library.
##
## The deal.II library is free software; you can use it, redistribute
## it, and/or modify it under the terms of the GNU Lesser General
## Public License as published by the Free Software Foundation; either
## version 2.1 of the License, or (at your option) any later version.
## The full text of the license can be found in the file LICENSE at
## the top level of the deal.II distribution.
##
## ---------------------------------------------------------------------
#
# Find MPI
#
# This module exports:
# MPI_LIBRARIES
# MPI_INCLUDE_DIRS
# MPI_CXX_FLAGS
# MPI_LINKER_FLAGS
# MPI_VERSION
# MPI_VERSION_MAJOR
# MPI_VERSION_MINOR
# OMPI_VERSION
# MPI_HAVE_MPI_SEEK_SET
#
#
# Configuration for mpi support:
#
# We look for the C and Fortran libraries as well because they are needed
# by some external libraries for the link interface.
#
IF(MPI_CXX_FOUND)
SET(MPI_FOUND TRUE)
ENDIF()
#
# Call the system FindMPI.cmake module:
#
# in case MPIEXEC is specified first call find_program() so that in case of
# success its subsequent runs inside FIND_PACKAGE(MPI) do not alter the
# desired result.
IF(DEFINED ENV{MPIEXEC})
FIND_PROGRAM(MPIEXEC $ENV{MPIEXEC})
ENDIF()
# temporarily disable ${CMAKE_SOURCE_DIR}/cmake/modules for module lookup
LIST(REMOVE_ITEM CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules/)
FIND_PACKAGE(MPI)
LIST(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules/)
#
# Older versions of MPI may not have MPI_SEEK_SET, which we
# require. Strangely, unlike MPICH, OpenMPI needs the correct link libraries
# for this to compile, not *just* the correct include directories.
#
CLEAR_CMAKE_REQUIRED()
SET(CMAKE_REQUIRED_FLAGS ${DEAL_II_CXX_FLAGS_SAVED} ${MPI_CXX_COMPILE_FLAGS} ${MPI_CXX_LINK_FLAGS})
SET(CMAKE_REQUIRED_INCLUDES ${MPI_CXX_INCLUDE_PATH})
SET(CMAKE_REQUIRED_LIBRARIES ${DEAL_II_LINKER_FLAGS_SAVED} ${MPI_LIBRARIES})
CHECK_CXX_SOURCE_COMPILES(
"
#include <mpi.h>
#ifndef MPI_SEEK_SET
# error
#endif
int main() {}
"
MPI_HAVE_MPI_SEEK_SET
)
RESET_CMAKE_REQUIRED()
#
# Newer versions of FindMPI.cmake only populate MPI_CXX_* (and MPI_C_*,
# MPI_Fortran_*) variables. Let's rename these version names
#
IF(NOT DEFINED MPI_VERSION AND DEFINED MPI_CXX_VERSION)
SET(MPI_VERSION ${MPI_CXX_VERSION})
SET(MPI_VERSION_MAJOR ${MPI_CXX_VERSION_MAJOR})
SET(MPI_VERSION_MINOR ${MPI_CXX_VERSION_MINOR})
ENDIF()
#
# Really old versions of CMake do not export any version information. In
# this case, query the mpi.h header for the necessary information:
#
DEAL_II_FIND_FILE(MPI_MPI_H
NAMES mpi.h
HINTS ${MPI_CXX_INCLUDE_PATH} ${MPI_C_INCLUDE_PATH}
)
IF(NOT MPI_MPI_H MATCHES "-NOTFOUND" AND NOT DEFINED MPI_VERSION)
FILE(STRINGS "${MPI_MPI_H}" MPI_VERSION_MAJOR_STRING
REGEX "#define.*MPI_VERSION")
STRING(REGEX REPLACE "^.*MPI_VERSION[ ]+([0-9]+).*" "\\1"
MPI_VERSION_MAJOR "${MPI_VERSION_MAJOR_STRING}"
)
FILE(STRINGS ${MPI_MPI_H} MPI_VERSION_MINOR_STRING
REGEX "#define.*MPI_SUBVERSION")
STRING(REGEX REPLACE "^.*MPI_SUBVERSION[ ]+([0-9]+).*" "\\1"
MPI_VERSION_MINOR "${MPI_VERSION_MINOR_STRING}"
)
SET(MPI_VERSION "${MPI_VERSION_MAJOR}.${MPI_VERSION_MINOR}")
#
# Except - this doesn't always work. Some distributions install a header
# stub mpi.h that includes the right mpi header depending on the
# architecture. In this case we are really out of luck. It is not
# straightforward to find the correct header file to query the version
# information from. Just set a very conservative default:
#
IF(MPI_VERSION STREQUAL ".")
SET(MPI_VERSION "0.0")
SET(MPI_VERSION_MAJOR "0")
SET(MPI_VERSION_MINOR "0")
ENDIF()
ENDIF()
DEAL_II_PACKAGE_HANDLE(MPI
LIBRARIES
OPTIONAL MPI_CXX_LIBRARIES MPI_Fortran_LIBRARIES MPI_C_LIBRARIES
INCLUDE_DIRS
OPTIONAL MPI_CXX_INCLUDE_PATH MPI_C_INCLUDE_PATH
USER_INCLUDE_DIRS
OPTIONAL MPI_CXX_INCLUDE_PATH MPI_C_INCLUDE_PATH
CXX_FLAGS OPTIONAL MPI_CXX_COMPILE_FLAGS
LINKER_FLAGS OPTIONAL MPI_CXX_LINK_FLAGS
CLEAR
MPI_C_COMPILER
MPI_CXX_COMPILER
MPIEXEC
MPI_EXTRA_LIBRARY
MPI_Fortran_COMPILER
MPI_HEADER_PATH
MPI_LIB
MPI_LIBRARY
MPI_MPI_H
MPI_HAVE_MPI_SEEK_SET
)
|