]> https://gitweb.dealii.org/ - dealii.git/commitdiff
CMake: Refactor MPI sanity check into setup_finalize.cmake 7816/head
authorMatthias Maier <tamiko@43-1.org>
Mon, 18 Mar 2019 18:06:20 +0000 (13:06 -0500)
committerMatthias Maier <tamiko@43-1.org>
Mon, 18 Mar 2019 18:06:20 +0000 (13:06 -0500)
cmake/configure/configure_1_mpi.cmake
cmake/setup_finalize.cmake

index f3f27eb92e5f7b9c502d94b721b393cbf837a195..a5929c59083855c038d6bd96ac679562d65a1477 100644 (file)
@@ -39,80 +39,6 @@ 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}"
-      "${_linker_flags} ${DEAL_II_LINKER_FLAGS_SAVED} ${MPI_LINKER_FLAGS}"
-      MPI_WORKING_COMPILER
-      ${DEAL_II_LIBRARIES} ${MPI_LIBRARIES}
-      )
-
-    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."
-        )
-
-      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}"
-        "${_linker_flags} ${DEAL_II_LINKER_FLAGS_SAVED} ${MPI_LINKER_FLAGS}"
-        MPI_WORKING_COMPILER
-        ${DEAL_II_LIBRARIES} ${MPI_LIBRARIES}
-        )
-    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()
 ENDMACRO()
 
index da1d0b9e77da5b3c253dc48edb4de421381c5134..1df5d7b27141a541a76e21fe29defea9beb75584 100644 (file)
@@ -84,12 +84,52 @@ ENDFOREACH()
 #
 
 FOREACH(build ${DEAL_II_BUILD_TYPES})
-  CHECK_COMPILER_SETUP(
-    "${DEAL_II_CXX_FLAGS} ${DEAL_II_CXX_FLAGS_${build}}"
-    "${DEAL_II_LINKER_FLAGS} ${DEAL_II_LINKER_FLAGS_${build}}"
-    DEAL_II_HAVE_USABLE_FLAGS_${build}
-    ${DEAL_II_LIBRARIES} ${DEAL_II_LIBRARIES_${build}}
-    )
+
+  MACRO(_check_linker_flags)
+    CHECK_COMPILER_SETUP(
+      "${DEAL_II_CXX_FLAGS} ${DEAL_II_CXX_FLAGS_${build}}"
+      "${DEAL_II_LINKER_FLAGS} ${DEAL_II_LINKER_FLAGS_${build}}"
+      DEAL_II_HAVE_USABLE_FLAGS_${build}
+      ${DEAL_II_LIBRARIES} ${DEAL_II_LIBRARIES_${build}}
+      )
+  ENDMACRO()
+
+  MACRO(_drop_linker_flag _linker_flag _replacement_flag _variable)
+    MESSAGE(STATUS
+      "Unable to compile a simple test program. "
+      "Trying to drop \"${_linker_flag}\" from the linker flags."
+      )
+    STRING(REPLACE "${_linker_flag}" "${_replacement_flag}"
+      DEAL_II_LINKER_FLAGS "${DEAL_II_LINKER_FLAGS}"
+      )
+    STRING(REPLACE "${_linker_flag}" "${_replacement_flag}"
+      DEAL_II_LINKER_FLAGS_${build} "${DEAL_II_LINKER_FLAGS_${_build}}"
+      )
+    SET(${_variable} FALSE CACHE INTERNAL "" FORCE)
+    SET(${_variable} FALSE)
+  ENDMACRO()
+
+  _check_linker_flags()
+
+  IF(NOT DEAL_II_HAVE_USABLE_FLAGS_${build} AND DEAL_II_COMPILER_HAS_FUSE_LD_LLD)
+    SET(_replacement "")
+    IF(DEAL_II_COMPILER_HAS_FUSE_LD_GOLD)
+      SET(_replacement "-fuse-ld=gold")
+    ENDIF()
+    _drop_linker_flag(
+      "-fuse-ld=lld" ${_replacement}
+      DEAL_II_COMPILER_HAS_FUSE_LD_LLD
+      )
+    _check_linker_flags()
+  ENDIF()
+
+  IF(NOT DEAL_II_HAVE_USABLE_FLAGS_${build} AND DEAL_II_COMPILER_HAS_FUSE_LD_GOLD)
+    _drop_linker_flag(
+      "-fuse-ld=gold" ""
+      DEAL_II_COMPILER_HAS_FUSE_LD_GOLD
+      )
+    _check_linker_flags()
+  ENDIF()
 
   IF(NOT DEAL_II_HAVE_USABLE_FLAGS_${build})
     MESSAGE(FATAL_ERROR "

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.