aboutsummaryrefslogtreecommitdiff
path: root/cmake/platform/unix
diff options
context:
space:
mode:
authorCarbenium <carbenium@outlook.com>2020-07-24 19:00:44 +0200
committerPeter Keresztes Schmidt <carbenium@outlook.com>2020-07-25 18:00:20 +0200
commit796e2b32e03e7b1a56e44bd4b8988f9156bbb026 (patch)
tree3a21e5e798b99a3b9ad58a192305511f64776593 /cmake/platform/unix
parent7ea33120a03d70aaa856c2c66f183d684131746e (diff)
Build: Add WITH_LD_GOLD option to use gold linker on unix
gold is an ELF-only linker which has a better performance than the default ld.
Diffstat (limited to 'cmake/platform/unix')
-rw-r--r--cmake/platform/unix/settings.cmake13
1 files changed, 13 insertions, 0 deletions
diff --git a/cmake/platform/unix/settings.cmake b/cmake/platform/unix/settings.cmake
index 51e0955977f..e86a14944bc 100644
--- a/cmake/platform/unix/settings.cmake
+++ b/cmake/platform/unix/settings.cmake
@@ -18,6 +18,19 @@ add_custom_target(uninstall
)
message(STATUS "UNIX: Created uninstall target")
+if(USE_LD_GOLD)
+ execute_process(COMMAND ${CMAKE_C_COMPILER} -fuse-ld=gold -Wl,--version ERROR_QUIET OUTPUT_VARIABLE LD_VERSION)
+ if("${LD_VERSION}" MATCHES "GNU gold")
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold")
+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fuse-ld=gold")
+ message(STATUS "UNIX: Using GNU gold linker")
+ else()
+ message(WARNING "UNIX: GNU gold linker isn't available, using the default system linker")
+ endif()
+else()
+ message(STATUS "UNIX: Using default system linker")
+endif()
+
message(STATUS "UNIX: Detected compiler: ${CMAKE_C_COMPILER}")
if(CMAKE_C_COMPILER MATCHES "gcc" OR CMAKE_C_COMPILER_ID STREQUAL "GNU")
include(${CMAKE_SOURCE_DIR}/cmake/compiler/gcc/settings.cmake)