]> https://gitweb.dealii.org/ - dealii.git/commitdiff
CMake: Refactor check for -fuse-ld=gold into check_01_compiler_features.cmake 1539/head
authorMatthias Maier <tamiko@43-1.org>
Sun, 6 Sep 2015 21:46:50 +0000 (16:46 -0500)
committerMatthias Maier <tamiko@43-1.org>
Sun, 6 Sep 2015 21:49:31 +0000 (16:49 -0500)
cmake/checks/check_01_compiler_features.cmake
cmake/setup_compiler_flags_gnu.cmake
cmake/setup_compiler_flags_intel.cmake

index 52b885223e2fb04497ef7d556c19260b7facf6be..d26a2f21e17bc8914d9c5b3280e2c92a955b9a37 100644 (file)
@@ -32,6 +32,7 @@
 #   DEAL_II_COMPILER_HAS_ATTRIBUTE_DEPRECATED
 #   DEAL_II_DEPRECATED
 #   DEAL_II_COMPILER_HAS_DIAGNOSTIC_PRAGMA
+#   DEAL_II_COMPILER_HAS_FUSE_LD_GOLD
 #
 
 
@@ -336,3 +337,26 @@ CHECK_CXX_SOURCE_COMPILES(
   DEAL_II_COMPILER_HAS_DIAGNOSTIC_PRAGMA)
 RESET_CMAKE_REQUIRED()
 
+
+#
+# Use the 'gold' linker if possible, given that it's substantially faster.
+#
+# We have to try to link a full executable with -fuse-ld=gold to check
+# whether "ld.gold" is actually available. gcc has the bad habit of
+# accepting the flag without emitting an error.
+#
+# Wolfgang Bangerth, Matthias Maier, 2015
+#
+PUSH_CMAKE_REQUIRED("-Werror")
+PUSH_CMAKE_REQUIRED("-fuse-ld=gold")
+CHECK_CXX_SOURCE_COMPILES(
+  "
+  int main() { return 0; }
+  "
+  DEAL_II_COMPILER_HAS_FUSE_LD_GOLD)
+RESET_CMAKE_REQUIRED()
+
+IF(DEAL_II_COMPILER_HAS_FUSE_LD_GOLD)
+  ADD_FLAGS(DEAL_II_LINKER_FLAGS "-fuse-ld=gold")
+ENDIF()
+
index e43680ccbf641b11e6c5d81949244439a1f13802..9409c36cc819c9c081acaba7480f46ea65955b38 100644 (file)
@@ -54,11 +54,6 @@ ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-fpic")
 #
 ENABLE_IF_LINKS(DEAL_II_LINKER_FLAGS "-Wl,--as-needed")
 
-#
-# Use the 'gold' linker if possible, given that it's substantially faster.
-#
-ENABLE_IF_SUPPORTED(DEAL_II_LINKER_FLAGS "-fuse-ld=gold")
-
 #
 # Setup various warnings:
 #
index 62b3c9e6b8b4d0e81a2f1112c79d372ede272e06..2232a64d037411f0c55511762359c985eada0509 100644 (file)
@@ -45,11 +45,6 @@ ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-fpic")
 #
 ENABLE_IF_LINKS(DEAL_II_LINKER_FLAGS "-Wl,--as-needed")
 
-#
-# Use the 'gold' linker if possible, given that it's substantially faster.
-#
-ENABLE_IF_SUPPORTED(DEAL_II_LINKER_FLAGS "-fuse-ld=gold")
-
 #
 # Set ansi mode:
 #

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.