summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathias Preiner <mathias.preiner@gmail.com>2020-02-10 11:34:11 -0800
committerGitHub <noreply@github.com>2020-02-10 11:34:11 -0800
commit779f9cd3c0f9a3620a52c30a853bde9e7b911494 (patch)
tree64279cbb1d8aa91edfad89a38d27b0fc0982e824
parent5c7d51d9195d94edcf422f8f81b417077b2c460c (diff)
cmake: Use ld.gold if available for faster link times. (#3738)
-rw-r--r--CMakeLists.txt13
1 files changed, 13 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1c187eff3..e5d0cf0e5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -241,6 +241,19 @@ add_check_c_cxx_flag("-Wimplicit-fallthrough")
add_check_cxx_flag("-Wno-class-memaccess")
#-----------------------------------------------------------------------------#
+# Use ld.gold if available
+
+execute_process(COMMAND ${CMAKE_C_COMPILER}
+ -fuse-ld=gold
+ -Wl,--version ERROR_QUIET OUTPUT_VARIABLE LD_VERSION)
+if ("${LD_VERSION}" MATCHES "GNU gold")
+ string(APPEND CMAKE_EXE_LINKER_FLAGS " -fuse-ld=gold")
+ string(APPEND CMAKE_SHARED_LINKER_FLAGS " -fuse-ld=gold")
+ string(APPEND CMAKE_MODULE_LINKER_FLAGS " -fuse-ld=gold")
+ message(STATUS "Using GNU gold linker.")
+endif ()
+
+#-----------------------------------------------------------------------------#
# Option defaults (three-valued options (cvc4_option(...)))
#
# These options are only set if their value is IGNORE. Otherwise, the user
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback