2 execute_process(COMMAND ${CMAKE_CXX_COMPILER} -fuse-ld=lld -Wl,--version ERROR_QUIET OUTPUT_VARIABLE LD_VERSION)
3 if(LD_VERSION MATCHES "LLD")
4 include(FindPackageHandleStandardArgs)
5 find_program(LLD_EXECUTABLE lld)
6 find_package_handle_standard_args(LLD REQUIRED_VARS LLD_EXECUTABLE)
9 set(CMAKE_LINKER ${LLD_EXECUTABLE})
10 set(CMAKE_CXX_LINK_FLAGS -fuse-ld=lld)
11 set(CMAKE_C_LINK_FLAGS -fuse-ld=lld)
12 set(CMAKE_EXE_LINKER_FLAGS "${LD_FLAGS} -fuse-ld=lld")
13 set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
14 set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
15 message(STATUS "Linker: LLVM lld")
17 mark_as_advanced(LLD_EXECUTABLE CMAKE_LINKER)
20 message(FATAL_ERROR "LLVM lld linker not found")