Skip to content

Configure CMAKE_<LANG>_USING_LINKER_<TYPE> in the Toolchain #161

Description

@MarkSchofield

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..?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions