mirror of
https://github.com/Kitware/CMake.git
synced 2026-03-01 04:08:46 -06:00
Linker configuration: rely now on CMAKE_<LANG>_LINK_MODE variable.
CMake now provides the CMAKE_<LANG>_LINK_MODE variable which specify how the link step is done. So, the CMAKE_<LANG>_USING_LINKER_MODE variable is no longer needed.
This commit is contained in:
@@ -15,3 +15,18 @@ variable should be interpreted. The supported linker mode values are:
|
||||
``TOOL``
|
||||
:variable:`CMAKE_<LANG>_USING_LINKER_<TYPE>` holds the path to the linker
|
||||
tool.
|
||||
|
||||
.. warning::
|
||||
|
||||
The variable must be set accordingly to how CMake manage the link step:
|
||||
|
||||
* value ``TOOL`` is expected and required when the linker is used directly
|
||||
for the link step.
|
||||
* value ``FLAGS`` is expected or the variable not set when the compiler is
|
||||
used as driver for the link step.
|
||||
|
||||
.. deprecated:: 4.0
|
||||
|
||||
This variable is no longer used. The type of information stored in the
|
||||
:variable:`CMAKE_<LANG>_USING_LINKER_<TYPE>` variable is determined by the
|
||||
:variable:`CMAKE_<LANG>_LINK_MODE` variable.
|
||||
|
||||
@@ -6,9 +6,15 @@ CMAKE_<LANG>_USING_LINKER_<TYPE>
|
||||
This variable defines how to specify the ``<TYPE>`` linker for the link step,
|
||||
as controlled by the :variable:`CMAKE_LINKER_TYPE` variable or the
|
||||
:prop_tgt:`LINKER_TYPE` target property. Depending on the value of the
|
||||
:variable:`CMAKE_<LANG>_USING_LINKER_MODE` variable,
|
||||
:variable:`CMAKE_<LANG>_LINK_MODE` variable,
|
||||
``CMAKE_<LANG>_USING_LINKER_<TYPE>`` can hold compiler flags for the link step,
|
||||
or flags to be given directly to the linker tool.
|
||||
or the path to the linker tool.
|
||||
|
||||
.. versionchanged:: 4.0
|
||||
|
||||
The type of information stored in this variable is now determined by the
|
||||
:variable:`CMAKE_<LANG>_LINK_MODE` variable instead of the
|
||||
:variable:`CMAKE_<LANG>_USING_LINKER_MODE` variable.
|
||||
|
||||
.. note::
|
||||
|
||||
@@ -19,21 +25,25 @@ For example, the ``LLD`` linker for ``GNU`` compilers is defined like so:
|
||||
|
||||
.. code-block:: cmake
|
||||
|
||||
# CMAKE_C_LINK_MODE holds value "DRIVER"
|
||||
set(CMAKE_C_USING_LINKER_LLD "-fuse-ld=lld")
|
||||
|
||||
On the ``Windows`` platform with ``Clang`` compilers simulating ``MSVC``:
|
||||
On the ``Windows`` platform with ``Clang`` compilers simulating ``MSVC`` with
|
||||
``GNU`` front-end:
|
||||
|
||||
.. code-block:: cmake
|
||||
|
||||
# CMAKE_C_LINK_MODE holds value "DRIVER"
|
||||
set(CMAKE_C_USING_LINKER_LLD "-fuse-ld=lld-link")
|
||||
|
||||
And for the ``MSVC`` compiler, the linker is invoked directly, not via the
|
||||
compiler frontend:
|
||||
And for the ``MSVC`` compiler or ``Clang`` compilers simulating ``MSVC`` with
|
||||
``MSVC`` front-end, the linker is invoked directly, not via the compiler
|
||||
front-end:
|
||||
|
||||
.. code-block:: cmake
|
||||
|
||||
# CMAKE_C_LINK_MODE holds value "LINKER"
|
||||
set(CMAKE_C_USING_LINKER_LLD "/path/to/lld-link.exe")
|
||||
set(CMAKE_C_USING_LINKER_MODE TOOL)
|
||||
|
||||
A custom linker type can also be defined, usually in a toolchain file:
|
||||
|
||||
@@ -41,4 +51,3 @@ A custom linker type can also be defined, usually in a toolchain file:
|
||||
|
||||
set(CMAKE_LINKER_TYPE lld_launcher)
|
||||
set(CMAKE_C_USING_LINKER_lld_launcher "-fuse-ld=/path/to/lld-launcher.sh")
|
||||
set(CMAKE_C_USING_LINKER_MODE FLAG)
|
||||
|
||||
Reference in New Issue
Block a user