As of CMake 3.29, the CMAKE_<LANG>_USING_LINKER_<TYPE> 'family' of variables can be used to control which linker is used for linking <LANG>. A given consumer would, say, set the CMAKE_LINKER_TYPE variable, or the LINKER_TYPE property on a target to a value of LLD, and then the CMAKE_<LANG>_USING_LINKER_<TYPE> (with <TYPE> replaced with LLD) variable would be used to link the target.
Given that the toolchain is responsible for setting variables for CMake to be able to use the tools from the toolchain, should the toolchain be responsible for setting, say, CMAKE_CXX_USING_LINKER_LLD to a discovered path of LLD so that the consumer is just responsible for setting CMAKE_LINKER_TYPE to LLD? That seems reasonable - a toolchain file could discover multiple linkers on the system and surface them. The one piece I don't get is CMAKE_<LANG>_LINK_MODE - it's value determines whether CMAKE_<LANG>_USING_LINKER_<TYPE> specifies a DRIVER or a LINKER. So if the toolchain is setting CMAKE_<LANG>_USING_LINKER_<TYPE>, then it would need to set CMAKE_<LANG>_LINK_MODE to explain that CMAKE_<LANG>_USING_LINKER_<TYPE> specifies a LINKER, but CMAKE_<LANG>_LINK_MODE isn't <TYPE> discriminated, so should be set by the consumer..?
As of CMake 3.29, the
CMAKE_<LANG>_USING_LINKER_<TYPE>'family' of variables can be used to control which linker is used for linking<LANG>. A given consumer would, say, set theCMAKE_LINKER_TYPEvariable, or theLINKER_TYPEproperty on a target to a value ofLLD, and then theCMAKE_<LANG>_USING_LINKER_<TYPE>(with<TYPE>replaced withLLD) variable would be used to link the target.Given that the toolchain is responsible for setting variables for CMake to be able to use the tools from the toolchain, should the toolchain be responsible for setting, say,
CMAKE_CXX_USING_LINKER_LLDto a discovered path of LLD so that the consumer is just responsible for settingCMAKE_LINKER_TYPEtoLLD? That seems reasonable - a toolchain file could discover multiple linkers on the system and surface them. The one piece I don't get isCMAKE_<LANG>_LINK_MODE- it's value determines whetherCMAKE_<LANG>_USING_LINKER_<TYPE>specifies aDRIVERor aLINKER. So if the toolchain is settingCMAKE_<LANG>_USING_LINKER_<TYPE>, then it would need to setCMAKE_<LANG>_LINK_MODEto explain thatCMAKE_<LANG>_USING_LINKER_<TYPE>specifies aLINKER, butCMAKE_<LANG>_LINK_MODEisn't<TYPE>discriminated, so should be set by the consumer..?