diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-05-02 15:11:29 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-05-02 15:14:12 +0300 |
commit | ca15ffb8ad8c25a18ac63eb096aa2c3aaaed7ea2 (patch) | |
tree | 4b57309c6b7601bdbd5d36a631e847467b3ea088 | |
parent | 929c9de3dc79f2b8c488ec9ff2138701dfa17175 (diff) |
CMake: use ld.gold linker when available
Gives noticeable speedup linking blender
-rw-r--r-- | CMakeLists.txt | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 9c7308e1fc2..44f6b2f8752 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1162,6 +1162,19 @@ if(UNIX AND NOT APPLE) # though some c11 features can still be used. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu89") endif() + + # use ld.gold linker if available, could make optional + 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_C_FLAGS "${CMAKE_C_FLAGS} -fuse-ld=gold") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fuse-ld=gold") + else () + message(WARNING "GNU gold linker isn't available, using the default system linker.") + endif () + unset(LD_VERSION) + # CLang is the same as GCC for now. elseif(CMAKE_C_COMPILER_ID MATCHES "Clang") set(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing") |