Skip to content

Commit

Permalink
cmake: use gold linker if available
Browse files Browse the repository at this point in the history
  • Loading branch information
dagar committed Oct 2, 2019
1 parent 3687677 commit 5126e6e
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,25 @@ endif()

#=============================================================================

# gold linker - use if available
include(CMakeDependentOption)
CMAKE_DEPENDENT_OPTION(USE_LD_GOLD
"Use GNU gold linker" ON
"NOT WIN32;NOT APPLE" OFF
)

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")
else()
set(USE_LD_GOLD OFF)
endif()
endif()

#=============================================================================

# Setup install paths
if (${PX4_PLATFORM} STREQUAL "posix")

Expand Down

0 comments on commit 5126e6e

Please sign in to comment.