Skip to content

Add options to specify the linker tool

Offer the capability, through variable CMAKE_LINKER_TYPE, as well as the target property LINKER_TYPE to specify which linker must be used.

The implementation of this capability is specified by variables specific to the language and linker type: CMAKE_<LANG>_USING_LINKER_<TYPE>. Some definitions are provided as part of CMake.

For example, to select the LLVM linker rather than the standard one, the type LLD should be specified through the variable CMAKE_LINKER_TYPE. And, on Apple, Linux and some environments on Windows, the variable CMAKE_<LANG>_USING_LINKER_LLD has value -fuse-ld=lld. And for Windows environments based on MSVC, where the linker is used directly, the tool lld-link.exe will be used rather than link.exe.

Fixes: #19174 (closed), #24254 (closed), #24990 (closed)

Merge request reports