1 # Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License.
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 MESSAGE(STATUS "Check for MPI ...")
27 IF(WITHOUT_MPI OR WITH_MPI STREQUAL 0)
29 MESSAGE(STATUS "mpi disabled from command line.")
30 ENDIF(WITHOUT_MPI OR WITH_MPI STREQUAL 0)
33 SET(MPI_ROOT_USER ${WITH_MPI})
35 SET(MPI_ROOT_USER $ENV{MPI_ROOT})
39 FIND_PROGRAM(MPICC mpicc)
41 MESSAGE(STATUS "mpicc found: ${MPICC}")
42 SET(MPI_ROOT ${MPICC})
43 GET_FILENAME_COMPONENT(MPI_ROOT ${MPI_ROOT} PATH)
44 GET_FILENAME_COMPONENT(MPI_ROOT ${MPI_ROOT} PATH)
45 IF(MPICC STREQUAL /usr/bin/mpicc)
46 ELSE(MPICC STREQUAL /usr/bin/mpicc)
47 SET(MPI_ROOT_USER ${MPI_ROOT})
48 ENDIF(MPICC STREQUAL /usr/bin/mpicc)
50 ELSE(NOT MPI_ROOT_USER)
51 SET(MPI_ROOT ${MPI_ROOT_USER})
52 ENDIF(NOT MPI_ROOT_USER)
57 MESSAGE(STATUS "MPI not found, try to use WITH_MPI option or MPI_ROOT environment variable.")
64 MESSAGE(STATUS "Check MPI in ${MPI_ROOT}")
66 SET(MPI_INCLUDE_TO_FIND mpi.h)
69 SET(MPI_ROOT ${MPI_ROOT_USER})
70 SET(MPI_INCLUDE_PATHS ${MPI_ROOT} ${MPI_ROOT}/include)
71 FIND_PATH(MPI_INCLUDES ${MPI_INCLUDE_TO_FIND} PATHS ${MPI_INCLUDE_PATHS} NO_DEFAULT_PATH)
73 MESSAGE(STATUS "MPI include ${MPI_INCLUDE_TO_FIND} not found in ${MPI_INCLUDE_PATHS}, check your MPI installation.")
75 ENDIF(NOT MPI_INCLUDES)
77 FIND_PATH(MPI_INCLUDES ${MPI_INCLUDE_TO_FIND})
79 MESSAGE(STATUS "MPI include ${MPI_INCLUDE_TO_FIND} not found on system, try to use WITH_MPI option or MPI_ROOT environment variable.")
81 ENDIF(NOT MPI_INCLUDES)
82 GET_FILENAME_COMPONENT(MPI_ROOT ${MPI_INCLUDES} PATH)
86 MESSAGE(STATUS "MPI include ${MPI_INCLUDE_TO_FIND} found in ${MPI_INCLUDES}")
88 SET(MPI_INCLUDE_DIR ${MPI_INCLUDES})
89 SET(MPI_INCLUDE_DIRS ${MPI_INCLUDES})
90 SET(MPI_INCLUDES -I${MPI_INCLUDES})# to remove
96 FIND_LIBRARY(MPI_LIB_THREAD libboost_thread-vc90-mt-gd-1_35 ${MPI_ROOT}/lib)
97 FIND_LIBRARY(MPI_LIB_DATE_TIME libboost_date_time-vc90-mt-gd-1_35 ${MPI_ROOT}/lib)
100 FOREACH(lib mpi_cxx mpi mpich)
101 FIND_LIBRARY(MPI_LIB_${lib} ${lib} ${MPI_ROOT}/lib)
104 ENDIF(MPI_LIB_${lib})
105 ENDFOREACH(lib mpi_cxx mpi mpich)
107 IF(MPI_LIB_mpi_cxx AND MPI_LIB_mpi)
108 SET(MPI_LIBS ${MPI_LIB_mpi_cxx} ${MPI_LIB_mpi})
109 SET(MPI_INCLUDES ${MPI_INCLUDES} -DOMPI_IGNORE_CXX_SEEK)# to remove
110 SET(MPI_DEFINITIONS -DOMPI_IGNORE_CXX_SEEK)
111 ELSEIF(MPI_LIB_mpi_cxx)
112 SET(MPI_LIBS ${MPI_LIB_mpi_cxx})
113 SET(MPI_INCLUDES ${MPI_INCLUDES} -DOMPI_IGNORE_CXX_SEEK)# to remove
114 SET(MPI_DEFINITIONS -DOMPI_IGNORE_CXX_SEEK)
116 SET(MPI_LIBS ${MPI_LIB_mpi})
117 SET(MPI_INCLUDES ${MPI_INCLUDES} -DOMPI_IGNORE_CXX_SEEK)# to remove
118 SET(MPI_DEFINITIONS -DOMPI_IGNORE_CXX_SEEK)
119 ELSEIF(MPI_LIB_mpich)
120 SET(MPI_LIBS ${MPI_LIB_mpich})
121 SET(MPI_INCLUDES ${MPI_INCLUDES} -DMPICH_IGNORE_CXX_SEEK)# to remove
122 SET(MPI_DEFINITIONS -DMPICH_IGNORE_CXX_SEEK)
125 MESSAGE(STATUS "MPI lib not found, check your MPI installation.")
129 MESSAGE(STATUS "MPI libs: ${MPI_LIBS}")
135 include(CheckSymbolExists)
136 SET(CMAKE_REQUIRED_LIBRARIES ${MPI_LIBS})
137 CHECK_SYMBOL_EXISTS(MPI_Publish_name ${MPI_INCLUDE_DIR}/mpi.h MPI2_IS_OK)
139 MESSAGE(STATUS "Your mpi implemtentation is compatible with mpi2 ... adding -DHAVE_MPI2")
140 SET(MPI_INCLUDES ${MPI_INCLUDES} -DHAVE_MPI2)# to remove
141 SET(MPI_DEFINITIONS "${MPI_DEFINITIONS} -DHAVE_MPI2")
151 MESSAGE(FATAL_ERROR "MPI not found but mandatory")
152 ELSE(MPI_IS_MANDATORY)
153 MESSAGE(STATUS "MPI not found. Build procedure depending of mpi will be disable")
154 ENDIF(MPI_IS_MANDATORY)