]> https://gitweb.dealii.org/ - dealii.git/commitdiff
CMake: Reorganize MPI sanity check
authorMatthias Maier <tamiko@43-1.org>
Fri, 15 Mar 2019 17:14:45 +0000 (12:14 -0500)
committerMatthias Maier <tamiko@43-1.org>
Mon, 18 Mar 2019 17:48:50 +0000 (12:48 -0500)
cmake/configure/configure_1_mpi.cmake

index f5e349b1126e120b1c408ba978e58fb3fa7477aa..f3f27eb92e5f7b9c502d94b721b393cbf837a195 100644 (file)
@@ -39,42 +39,78 @@ MACRO(FEATURE_MPI_FIND_EXTERNAL var)
       SET(${var} FALSE)
     ENDIF()
 
+    #
+    # Check that we can link with the full MPI interface:
+    #
+
+    SET(_linker_flags "${DEAL_II_LINKER_FLAGS}")
+
     CHECK_COMPILER_SETUP(
       "${DEAL_II_CXX_FLAGS} ${DEAL_II_CXX_FLAGS_SAVED} ${MPI_CXX_FLAGS}"
-      "${DEAL_II_LINKER_FLAGS} ${DEAL_II_LINKER_FLAGS_SAVED} ${MPI_LINKER_FLAGS}"
+      "${_linker_flags} ${DEAL_II_LINKER_FLAGS_SAVED} ${MPI_LINKER_FLAGS}"
       MPI_WORKING_COMPILER
       ${DEAL_II_LIBRARIES} ${MPI_LIBRARIES}
       )
 
-    IF(NOT MPI_WORKING_COMPILER)
-      #
-      # Try a workaround and drop "-fuse-ld=gold" (if present) from the
-      # linker invocation
-      #
-      MESSAGE(STATUS "Unable to compile a simple test program. "
-        "Try to drop \"-fuse-ld=gold\" from the linker flags."
+    IF(NOT MPI_WORKING_COMPILER AND DEAL_II_COMPILER_HAS_FUSE_LD_LLD)
+      MESSAGE(STATUS
+        "Unable to compile a simple test program. "
+        "Trying to drop \"-fuse-ld=lld\" from the linker flags."
         )
-      STRING(REPLACE "-fuse-ld=gold" "" _filtered_flags "${DEAL_II_LINKER_FLAGS}")
+
+      IF(DEAL_II_COMPILER_HAS_FUSE_LD_GOLD)
+        STRING(REPLACE "-fuse-ld=lld" "-fuse-ld=gold"
+          _linker_flags "${_linker_flags}"
+          )
+      ELSE()
+        STRING(REPLACE "-fuse-ld=lld" ""
+          _linker_flags "${_linker_flags}"
+          )
+      ENDIF()
+
+      SET(DEAL_II_COMPILER_HAS_FUSE_LD_LLD FALSE CACHE INTERNAL "" FORCE)
+      SET(DEAL_II_COMPILER_HAS_FUSE_LD_LLD FALSE)
 
       CHECK_COMPILER_SETUP(
         "${DEAL_II_CXX_FLAGS} ${DEAL_II_CXX_FLAGS_SAVED} ${MPI_CXX_FLAGS}"
-        "${_filtered_flags} ${DEAL_II_LINKER_FLAGS_SAVED} ${MPI_LINKER_FLAGS}"
+        "${_linker_flags} ${DEAL_II_LINKER_FLAGS_SAVED} ${MPI_LINKER_FLAGS}"
         MPI_WORKING_COMPILER
         ${DEAL_II_LIBRARIES} ${MPI_LIBRARIES}
         )
+    ENDIF()
 
-      IF(MPI_WORKING_COMPILER)
-        SET(DEAL_II_LINKER_FLAGS "${_filtered_flags}")
-      ELSE()
-        MESSAGE(STATUS "Could not find a sufficient MPI installation: "
-          "Unable to compile a simple test program."
-          )
-        SET(MPI_ADDITIONAL_ERROR_STRING
-          ${MPI_ADDITIONAL_ERROR_STRING}
-          "Unable to compile and link a simple test program with your MPI installation. \n"
-          )
-        SET(${var} FALSE)
-      ENDIF()
+    IF(NOT MPI_WORKING_COMPILER AND DEAL_II_COMPILER_HAS_FUSE_LD_GOLD)
+      MESSAGE(STATUS
+        "Unable to compile a simple test program. "
+        "Trying to drop \"-fuse-ld=gold\" from the linker flags."
+        )
+
+      STRING(REPLACE "-fuse-ld=gold" ""
+        _linker_flags "${_linker_flags}"
+        )
+
+      SET(DEAL_II_COMPILER_HAS_FUSE_LD_GOLD FALSE CACHE INTERNAL "" FORCE)
+      SET(DEAL_II_COMPILER_HAS_FUSE_LD_GOLD FALSE)
+
+      CHECK_COMPILER_SETUP(
+        "${DEAL_II_CXX_FLAGS} ${DEAL_II_CXX_FLAGS_SAVED} ${MPI_CXX_FLAGS}"
+        "${_linker_flags} ${DEAL_II_LINKER_FLAGS_SAVED} ${MPI_LINKER_FLAGS}"
+        MPI_WORKING_COMPILER
+        ${DEAL_II_LIBRARIES} ${MPI_LIBRARIES}
+        )
+    ENDIF()
+
+    IF(MPI_WORKING_COMPILER)
+      SET(DEAL_II_LINKER_FLAGS "${_linker_flags}")
+    ELSE()
+      MESSAGE(STATUS "Could not find a sufficient MPI installation: "
+        "Unable to compile a simple test program."
+        )
+      SET(MPI_ADDITIONAL_ERROR_STRING
+        ${MPI_ADDITIONAL_ERROR_STRING}
+        "Unable to compile and link a simple test program with your MPI installation. \n"
+        )
+      SET(${var} FALSE)
     ENDIF()
 
   ENDIF()

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.