]> https://gitweb.dealii.org/ - dealii.git/commitdiff
CMake: split compiler/linker flags sanity checks into extra file
authorMatthias Maier <tamiko@43-1.org>
Mon, 3 Jul 2023 05:36:42 +0000 (00:36 -0500)
committerMatthias Maier <tamiko@43-1.org>
Mon, 3 Jul 2023 15:27:31 +0000 (10:27 -0500)
CMakeLists.txt
cmake/setup_finalize.cmake
cmake/setup_sanity_checks.cmake [new file with mode: 0644]

index af84712d6f0cc6c4d21bcd93dad5383c6bfe58e2..769587f60686cb29a9aa99014abafe59149ee1a2 100644 (file)
@@ -111,6 +111,9 @@ foreach(_file ${_check_files})
   verbose_include(${_file})
 endforeach()
 
+# include setup_finalize.cmake before any target definitions
+verbose_include(${CMAKE_SOURCE_DIR}/cmake/setup_finalize.cmake)
+
 #
 # Feature configuration:
 #
@@ -120,8 +123,7 @@ foreach(_file ${_configure_files})
   verbose_include(${_file})
 endforeach()
 
-verbose_include(${CMAKE_SOURCE_DIR}/cmake/setup_finalize.cmake)
-
+verbose_include(${CMAKE_SOURCE_DIR}/cmake/setup_sanity_checks.cmake)
 verbose_include(${CMAKE_SOURCE_DIR}/cmake/setup_cpack.cmake)
 verbose_include(${CMAKE_SOURCE_DIR}/cmake/setup_custom_targets.cmake)
 
index 33acd1dadb97e5eaf94438e8c12e4173079a32f6..4fbfd19c0cfcb3782cdf5c1df23b01eabb4d4b54 100644 (file)
@@ -50,89 +50,6 @@ foreach(_flag ${DEAL_II_REMOVED_FLAGS})
   endif()
 endforeach()
 
-#
-# Sanity check: Can we compile with the final setup?
-#
-
-foreach(build ${DEAL_II_BUILD_TYPES})
-  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}}
-      ${DEAL_II_TARGETS} ${DEAL_II_TARGETS_${build}}
-      )
-  endmacro()
-
-  macro(_set_cache_variable _variable _value)
-    set(${_variable} ${_value} CACHE INTERNAL "" FORCE)
-    set(${_variable} ${_value})
-  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."
-      )
-    foreach(_flags
-        DEAL_II_LINKER_FLAGS DEAL_II_LINKER_FLAGS_${build}
-        BASE_LINKER_FLAGS BASE_LINKER_FLAGS_${build}
-        )
-      string(REPLACE "${_linker_flag}" "${_replacement_flag}"
-        ${_flags} "${${_flags}}"
-        )
-    endforeach()
-    _set_cache_variable(_variable FALSE)
-  endmacro()
-
-  _check_linker_flags()
-
-  if(NOT DEAL_II_HAVE_USABLE_FLAGS_${build} AND DEAL_II_COMPILER_HAS_FUSE_LD_MOLD)
-    set(_replacement "")
-    if(DEAL_II_COMPILER_HAS_FUSE_LD_LLD)
-      set(_replacement "-fuse-ld=lld")
-    elseif(DEAL_II_COMPILER_HAS_FUSE_LD_GOLD)
-      set(_replacement "-fuse-ld=gold")
-    endif()
-    _drop_linker_flag(
-      "-fuse-ld=mold" ${_replacement}
-      DEAL_II_COMPILER_HAS_FUSE_LD_MOLD
-      )
-    _check_linker_flags()
-  endif()
-
-  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 "
-  Configuration error: Cannot compile a test program with the final set of
-  compiler and linker flags:
-    CXX flags (${build}): ${DEAL_II_CXX_FLAGS} ${DEAL_II_CXX_FLAGS_${build}}
-    LD flags  (${build}): ${DEAL_II_LINKER_FLAGS} ${DEAL_II_LINKER_FLAGS_${build}}
-    LIBRARIES (${build}): ${DEAL_II_LIBRARIES};${DEAL_II_LIBRARIES_${build}}
-  \n\n"
-      )
-  endif()
-endforeach()
 
 #
 # Clean up deal.IITargets.cmake in the build directory:
diff --git a/cmake/setup_sanity_checks.cmake b/cmake/setup_sanity_checks.cmake
new file mode 100644 (file)
index 0000000..fa66f3f
--- /dev/null
@@ -0,0 +1,105 @@
+## ---------------------------------------------------------------------
+##
+## Copyright (C) 2012 - 2023 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.md at
+## the top level directory of deal.II.
+##
+## ---------------------------------------------------------------------
+
+
+########################################################################
+#                                                                      #
+#                            Sanity checks:                            #
+#                                                                      #
+########################################################################
+
+#
+# Sanity check: Can we compile with the final setup?
+#
+
+foreach(build ${DEAL_II_BUILD_TYPES})
+  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}}
+      ${DEAL_II_TARGETS} ${DEAL_II_TARGETS_${build}}
+      )
+  endmacro()
+
+  macro(_set_cache_variable _variable _value)
+    set(${_variable} ${_value} CACHE INTERNAL "" FORCE)
+    set(${_variable} ${_value})
+  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."
+      )
+    foreach(_flags
+        DEAL_II_LINKER_FLAGS DEAL_II_LINKER_FLAGS_${build}
+        BASE_LINKER_FLAGS BASE_LINKER_FLAGS_${build}
+        )
+      string(REPLACE "${_linker_flag}" "${_replacement_flag}"
+        ${_flags} "${${_flags}}"
+        )
+    endforeach()
+    _set_cache_variable(_variable FALSE)
+  endmacro()
+
+  _check_linker_flags()
+
+  if(NOT DEAL_II_HAVE_USABLE_FLAGS_${build} AND DEAL_II_COMPILER_HAS_FUSE_LD_MOLD)
+    set(_replacement "")
+    if(DEAL_II_COMPILER_HAS_FUSE_LD_LLD)
+      set(_replacement "-fuse-ld=lld")
+    elseif(DEAL_II_COMPILER_HAS_FUSE_LD_GOLD)
+      set(_replacement "-fuse-ld=gold")
+    endif()
+    _drop_linker_flag(
+      "-fuse-ld=mold" ${_replacement}
+      DEAL_II_COMPILER_HAS_FUSE_LD_MOLD
+      )
+    _check_linker_flags()
+  endif()
+
+  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 "
+  Configuration error: Cannot compile a test program with the final set of
+  compiler and linker flags:
+    CXX flags (${build}): ${DEAL_II_CXX_FLAGS} ${DEAL_II_CXX_FLAGS_${build}}
+    LD flags  (${build}): ${DEAL_II_LINKER_FLAGS} ${DEAL_II_LINKER_FLAGS_${build}}
+    LIBRARIES (${build}): ${DEAL_II_LIBRARIES};${DEAL_II_LIBRARIES_${build}}
+  \n\n"
+      )
+  endif()
+endforeach()

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.