]> https://gitweb.dealii.org/ - dealii.git/commitdiff
CMake: Check for MPI compatibility
authorMatthias Maier <tamiko@kyomu.43-1.org>
Thu, 15 May 2014 18:18:46 +0000 (18:18 +0000)
committerMatthias Maier <tamiko@kyomu.43-1.org>
Thu, 15 May 2014 18:18:46 +0000 (18:18 +0000)
git-svn-id: https://svn.dealii.org/trunk@32909 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/cmake/configure/configure_1_mpi.cmake
deal.II/cmake/configure/configure_2_metis.cmake
deal.II/cmake/configure/configure_2_trilinos.cmake
deal.II/cmake/configure/configure_3_petsc.cmake
deal.II/cmake/configure/configure_hdf5.cmake
deal.II/cmake/configure/configure_mumps.cmake
deal.II/cmake/configure/configure_p4est.cmake
deal.II/cmake/macros/macro_check_mpi_interface.cmake [new file with mode: 0644]
deal.II/cmake/modules/FindPETSC.cmake

index a73e27d962eab0c0599e3970196059bd0e546e8c..1fd25d1bf049a9d3afc8ec67c4d00276036baf83 100644 (file)
@@ -143,7 +143,9 @@ MACRO(FEATURE_MPI_FIND_EXTERNAL var)
   #
   # Populate correct variables:
   #
-  SET(MPI_LIBRARIES ${MPI_CXX_LIBRARIES})
+  SET(MPI_LIBRARIES
+    ${MPI_CXX_LIBRARIES} ${MPI_Fortran_LIBRARIES} ${MPI_C_LIBRARIES}
+    )
   SET(MPI_INCLUDE_DIRS ${MPI_CXX_INCLUDE_PATH})
   SET(MPI_CXX_FLAGS ${MPI_CXX_COMPILE_FLAGS})
   SET(MPI_LINKER_FLAGS "${MPI_CXX_LINK_FLAGS}")
index 34a47ca1d8e397872336930fbaa30effe542ed56..72a142286d6a1e4c84c78a2d299c7f38d611872c 100644 (file)
 ##
 ## ---------------------------------------------------------------------
 
+IF(NOT FEATURE_MPI_PROCESSED)
+  MESSAGE(FATAL_ERROR "\n"
+    "Internal build system error:\n"
+    "configure_2_metis.cmake included before configure_1_mpi.cmake\n\n"
+    )
+ENDIF()
+
 #
 # Configuration for the metis library:
 #
 MACRO(FEATURE_METIS_FIND_EXTERNAL var)
   FIND_PACKAGE(METIS)
 
-  IF(METIS_FOUND AND METIS_VERSION_MAJOR GREATER 4)
+  IF(METIS_FOUND)
     SET(${var} TRUE)
-  ELSE()
-    MESSAGE(STATUS "Insufficient metis installation found: "
-      "Version 5.x required!"
-      )
-    SET(METIS_ADDITIONAL_ERROR_STRING
-      "Could not find a sufficient modern metis installation: "
-      "Version 5.x required!\n"
-      )
+
+    IF(NOT METIS_VERSION_MAJOR GREATER 4)
+      MESSAGE(STATUS "Insufficient metis installation found: "
+        "Version 5.x required!"
+        )
+      SET(METIS_ADDITIONAL_ERROR_STRING
+        "Could not find a sufficient modern metis installation: "
+        "Version 5.x required!\n"
+        )
+      SET(${var} FALSE)
+    ENDIF()
+
+    CHECK_MPI_INTERFACE(METIS ${var})
   ENDIF()
 ENDMACRO()
 
index 2977f388469929c9164b55f6917a26076db45ba6..7b680a4f5e070f7acd94d1800e3f722e37012a66 100644 (file)
@@ -179,6 +179,8 @@ MACRO(FEATURE_TRILINOS_FIND_EXTERNAL var)
         SET(${var} FALSE)
       ENDIF()
     ENDIF()
+
+    CHECK_MPI_INTERFACE(TRILINOS ${var})
   ENDIF()
 ENDMACRO()
 
index 60d0f8e10bae4443671f756102feeccdac4547e8..ee95cd5a4a1a3e20d204c9b1dd3013050c2108ff 100644 (file)
@@ -93,6 +93,8 @@ MACRO(FEATURE_PETSC_FIND_EXTERNAL var)
         )
       SET(${var} FALSE)
     ENDIF()
+
+    CHECK_MPI_INTERFACE(PETSC ${var})
   ENDIF()
 ENDMACRO()
 
index c86c9612f0a89f57949a9293b527e876147f1a3c..abc66f4c04ad2053984e7c98ea8d496b17bbf8de 100644 (file)
 ##
 ## ---------------------------------------------------------------------
 
+IF(NOT FEATURE_MPI_PROCESSED)
+  MESSAGE(FATAL_ERROR "\n"
+    "Internal build system error:\n"
+    "configure_hdf5.cmake included before configure_1_mpi.cmake\n\n"
+    )
+ENDIF()
+
 #
 # Configuration for the hdf5 library:
 #
@@ -22,12 +29,10 @@ MACRO(FEATURE_HDF5_FIND_EXTERNAL var)
   FIND_PACKAGE(HDF5)
 
   IF(HDF5_FOUND)
-    IF( (HDF5_WITH_MPI AND DEAL_II_WITH_MPI) OR
-        (NOT HDF5_WITH_MPI AND NOT DEAL_II_WITH_MPI) )
-      SET(${var} TRUE)
-
-    ELSE()
+    SET(${var} TRUE)
 
+    IF( (HDF5_WITH_MPI AND NOT DEAL_II_WITH_MPI) OR
+        (NOT HDF5_WITH_MPI AND DEAL_II_WITH_MPI) )
       MESSAGE(STATUS "Insufficient hdf5 installation found: "
         "hdf5 has to be configured with the same MPI configuration as deal.II."
         )
@@ -37,7 +42,10 @@ MACRO(FEATURE_HDF5_FIND_EXTERNAL var)
         "  DEAL_II_WITH_MPI = ${DEAL_II_WITH_MPI}\n"
         "  HDF5_WITH_MPI    = ${HDF5_WITH_MPI}\n"
         )
+      SET(${var} FALSE)
     ENDIF()
+
+    CHECK_MPI_INTERFACE(HDF5 ${var})
   ENDIF()
 ENDMACRO()
 
index 78b4bb0b008ae9d47f49a18c44b51fed8d72c344..cfe08a2cdd6ab1f380dbed6b03a466636f89f2a9 100644 (file)
 
 SET(FEATURE_MUMPS_DEPENDS DEAL_II_WITH_MPI DEAL_II_WITH_LAPACK)
 
+
+MACRO(FEATURE_MUMPS_FIND_EXTERNAL var)
+  FIND_PACKAGE(MUMPS)
+
+  IF(MUMPS_FOUND)
+    SET(${var} TRUE)
+    CHECK_MPI_INTERFACE(MUMPS ${var})
+  ENDIF()
+ENDMACRO()
+
 CONFIGURE_FEATURE(MUMPS)
index 967b10b5657be7d85899e9abf6ef47ef14e418e2..313b8359ef4d4ec5e5a5af062054b64ee5f481b2 100644 (file)
@@ -54,6 +54,8 @@ MACRO(FEATURE_P4EST_FIND_EXTERNAL var)
         )
       SET(${var} FALSE)
     ENDIF()
+
+    CHECK_MPI_INTERFACE(P4EST ${var})
   ENDIF()
 ENDMACRO()
 
diff --git a/deal.II/cmake/macros/macro_check_mpi_interface.cmake b/deal.II/cmake/macros/macro_check_mpi_interface.cmake
new file mode 100644 (file)
index 0000000..0011282
--- /dev/null
@@ -0,0 +1,59 @@
+## ---------------------------------------------------------------------
+## $Id$
+##
+## Copyright (C) 2014 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.
+##
+## ---------------------------------------------------------------------
+
+#
+# Check whether a feature is compiled against the same MPI library as the
+# one deal.II picked up
+#
+# Usage:
+#     CHECK_MPI_INTERFACE(_feature _var),
+#
+
+MACRO(CHECK_MPI_INTERFACE _feature _var)
+  IF(DEAL_II_WITH_MPI)
+    SET(_nope FALSE)
+
+    FOREACH(_library ${${_feature}_LIBRARIES})
+      IF(_library MATCHES "/libmpi[^/]*\\.so")
+        LIST(FIND MPI_LIBRARIES "${_library}" _position)
+        IF("${_position}" STREQUAL "-1")
+          SET(_nope TRUE)
+          SET(_mpi_library ${_library})
+          BREAK()
+        ENDIF()
+      ENDIF()
+    ENDFOREACH()
+
+    IF(_nope)
+      MESSAGE(STATUS "Could not find a sufficient ${_feature} installation: "
+        "${_feature} is compiled against a different MPI library than the one "
+        "deal.II picked up."
+        )
+      TO_STRING(_str ${MPI_LIBRARIES})
+      SET(PETSC_ADDITIONAL_ERROR_STRING
+        ${PETSC_ADDITIONAL_ERROR_STRING}
+        "Could not find a sufficient ${_feature} installation:\n"
+        "${_feature} has to be compiled against the same MPI library as deal.II "
+        "but the link line of ${_feature} contains:\n"
+        "  ${_mpi_library}\n"
+        "which is not listed in MPI_LIBRARIES:\n"
+        "  MPI_LIBRARIES = \"${_str}\"\n"
+        )
+      SET(${_var} FALSE)
+    ENDIF()
+  ENDIF()
+ENDMACRO()
+
index 7151fb657f78c8967fd31aa959524f0aa3f165af..4cc4aef5198fbef9b608480816584c888c87bfe5 100644 (file)
@@ -176,11 +176,6 @@ IF(NOT PETSC_PETSCVARIABLES MATCHES "-NOTFOUND")
     REGEX "^PETSC_WITH_EXTERNAL_LIB =.*")
   SEPARATE_ARGUMENTS(PETSC_EXTERNAL_LINK_LINE)
 
-  IF(NOT "${PETSC_EXTERNAL_LINK_LINE}" STREQUAL "${PETSC_EXTERNAL_LINK_LINE_SAVED}")
-    SET(_new_petsc_external_link_line TRUE)
-  ENDIF()
-  SET(PETSC_EXTERNAL_LINK_LINE_SAVED "${PETSC_EXTERNAL_LINK_LINE}" CACHE INTERNAL "" FORCE)
-
   SET(_hints)
   SET(_petsc_libraries)
   SET(_cleanup_variables)
@@ -193,11 +188,7 @@ IF(NOT PETSC_PETSCVARIABLES MATCHES "-NOTFOUND")
       # Search for every library that was specified with -l:
       STRING(REGEX REPLACE "^-l" "" _token "${_token}")
 
-      # TODO:
       LIST(APPEND _cleanup_variables PETSC_LIBRARY_${_token})
-      IF(_new_petsc_external_link_line)
-        UNSET(PETSC_LIBRARY_${_token} CACHE)
-      ENDIF()
 
       IF(_token MATCHES "^(c|quadmath|gfortran|m|rt|nsl|dl|pthread)$")
         FIND_SYSTEM_LIBRARY(PETSC_LIBRARY_${_token} NAMES ${_token})

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.