LINKER_TYPEΒΆ
New in version 3.29.
Specify which linker will be used for the link step. The property value may use
generator expressions.
Note
It is assumed that the linker specified is fully compatible with the default one the compiler would normally invoke. CMake will not do any option translation.
Linker types are case-sensitive and may only contain letters, numbers and underscores. Linker types defined in all uppercase are reserved for CMake's own built-in types. The pre-defined linker types are:
- DEFAULT
- This type corresponds to standard linking, essentially equivalent to the - LINKER_TYPEtarget property not being set at all.
- SYSTEM
- Use the standard linker provided by the platform or toolchain. For example, this implies the Microsoft linker for all MSVC-compatible compilers. This type is supported for the following platform-compiler combinations: - Linux: - GNU,- Clang,- LLVMFlang,- NVIDIA, and- Swiftcompilers.
- Apple platforms: - AppleClang,- Clang,- GNU, and- Swiftcompilers.
- Windows: - MSVC,- GNU,- Clang,- NVIDIA, and- Swiftcompilers.
 
- LLD
- Use the - LLVMlinker. This type is supported for the following platform-compiler combinations:- Linux: - GNU,- Clang,- LLVMFlang,- NVIDIA, and- Swiftcompilers.
- Apple platforms: - Clang,- AppleClang, and- Swiftcompilers.
- Windows: - GNU,- Clangwith MSVC-like front-end,- Clangwith GNU-like front-end,- MSVC,- NVIDIAwith MSVC-like front-end, and- Swift.
 
- BFD
- Use the - GNUlinker. This type is supported for the following platform-compiler combinations:- Linux: - GNU,- Clang,- LLVMFlang, and- NVIDIAcompilers.
- Windows: - GNU,- Clangwith GNU-like front-end.
 
- GOLD
- Supported on Linux platform with - GNU,- Clang,- LLVMFlang,- NVIDIA, and- Swiftcompilers.
- MOLD
- Use the mold linker. This type is supported on the following platform-compiler combinations: - Linux: - GNU,- Clang,- LLVMFlang, and- NVIDIAcompilers.
- Apple platforms: - Clangand- AppleClangcompilers (acts as an alias to the sold linker).
 
- SOLD
- Use the sold linker. This type is only supported on Apple platforms with - Clangand- AppleClangcompilers.
- APPLE_CLASSIC
- Use the Apple linker in the classic behavior (i.e. before - Xcode 15.0). This type is only supported on Apple platforms with- GNU,- Clang,- AppleClang, and- Swiftcompilers.
- MSVC
- Use the Microsoft linker. This type is only supported on the Windows platform with - MSVC,- Clangwith MSVC-like front-end, and- Swiftcompilers.
This property is not supported on Green Hills MULTI generator.
The implementation details for the selected linker will be provided by the
CMAKE_<LANG>_USING_LINKER_<TYPE> variable. For example:
add_library(lib1 SHARED ...)
set_property(TARGET lib1 PROPERTY LINKER_TYPE LLD)
This specifies that lib1 should use linker type LLD for the link step.
The command line options that will be passed to the toolchain will be provided
by the CMAKE_<LANG>_USING_LINKER_LLD variable.
Note that the linker would typically be set using CMAKE_LINKER_TYPE
for the whole build rather than setting the LINKER_TYPE property on
individual targets.
