1# Copyright (C) 2013 CEA/DEN, EDF R&D, OPEN CASCADE 2# 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. 7# 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. 12# 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 16# 17# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com 18# 19# Author: Adrien Bruneton 20# 21 22# MPI detection for med-file 23 24# 1. Load environment or any previously detected MPI 25IF(DEFINED ENV{MPI_ROOT_DIR}) 26 FILE(TO_CMAKE_PATH "$ENV{MPI_ROOT_DIR}" _MPI_ROOT_DIR_ENV) 27 SET(_dflt_value "${_MPI_ROOT_DIR_ENV}") 28ELSE() 29 # will be blank if no MPI was previously loaded 30 SET(_dflt_value "${MPI_ROOT_DIR_EXP}") 31ENDIF() 32 33# Make cache entry 34SET(MPI_ROOT_DIR "${_dflt_value}" CACHE PATH "Path to MPI directory") 35 36# 2. Find package - config mode is impossible as MPI is compiled with autotools 37IF(EXISTS "${MPI_ROOT_DIR}") 38 SET(CMAKE_PREFIX_PATH "${MPI_ROOT_DIR}") 39ENDIF() 40INCLUDE(medMacros) 41SALOME_FIND_PACKAGE(MedfileMPI MPI MODULE) 42SET(MEDFILEMPI_FOUND ${MPI_FOUND}) 43 44IF(MPI_FOUND OR MPIEXEC) # MPI_FOUND is declared as deprecated in CMake doc 45 MESSAGE(STATUS "Found MPI!") 46 47 # 3. Set the root dir which was finally retained 48 # Extract it from MPIEXEC: 49 GET_FILENAME_COMPONENT(_tmp "${MPIEXEC}" REALPATH) # dereference symlinks 50 GET_FILENAME_COMPONENT(_tmp "${_tmp}" PATH) # go up one level in the path 51 GET_FILENAME_COMPONENT(_tmp_ROOT_DIR "${_tmp}" PATH) 52 53 # 4. Warn if CMake found something not located under ENV(XYZ_ROOT_DIR) 54 IF(DEFINED ENV{MPI_ROOT_DIR}) 55 SALOME_CHECK_EQUAL_PATHS(_res "${_tmp_ROOT_DIR}" "${_MPI_ROOT_DIR_ENV}") 56 IF(NOT _res) 57 MESSAGE(WARNING "MPI was found, but not at the path given by the " 58"environment MPI_ROOT_DIR! Is the variable correctly set?") 59 ELSE() 60 MESSAGE(STATUS "MPI found directory matches what was specified in the MPI_ROOT_DIR, all good!") 61 ENDIF() 62 ENDIF() 63 64 # Check for potential conflicts with previously configured MPI: 65 IF(MPI_ROOT_DIR_EXP) 66 SALOME_CHECK_EQUAL_PATHS(_res "${_tmp_ROOT_DIR}" "${MPI_ROOT_DIR_EXP}") 67 IF(NOT _res) 68 MESSAGE(WARNING "Warning: MPI: detected version conflicts with a previously found MPI!" 69 " The two paths are " ${_tmp_ROOT_DIR} " vs " ${MPI_ROOT_DIR_EXP}) 70 ELSE() 71 MESSAGE(STATUS "MPI directory matches what was previously exposed by another prereq, all good!") 72 ENDIF() 73 ENDIF() 74 75 # 6. Include directories: 76 SET(MPI_INCLUDE_DIRS ${MPI_CXX_INCLUDE_PATH}) 77 LIST(APPEND MPI_INCLUDE_DIRS ${MPI_C_INCLUDE_DIR}) 78 LIST(APPEND MPI_INCLUDE_DIRS ${MPI_Fortran_INCLUDE_DIR}) 79 80 MARK_AS_ADVANCED(MPI_EXTRA_LIBRARY MPI_LIBRARY) 81 82 SET(MPI_ROOT_DIR ${_tmp_ROOT_DIR}) 83 84 SET(MED_DEFINE_MED_HAVE_MPI "#define MED_HAVE_MPI") 85 86ELSE(MPI_FOUND OR MPIEXEC) 87 MESSAGE(STATUS "MPI was not found.") 88ENDIF(MPI_FOUND OR MPIEXEC) 89