cmake/Help/command/LINK_OPTIONS_LINKER.txt

26 lines
1.1 KiB
Plaintext
Raw Normal View History

2021-09-14 00:13:48 +02:00
Handling Compiler Driver Differences
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2020-02-01 23:06:01 +01:00
To pass options to the linker tool, each compiler driver has its own syntax.
The ``LINKER:`` prefix and ``,`` separator can be used to specify, in a portable
way, options to pass to the linker tool. ``LINKER:`` is replaced by the
appropriate driver option and ``,`` by the appropriate driver separator.
The driver prefix and driver separator are given by the values of the
2018-10-28 12:09:07 +01:00
:variable:`CMAKE_<LANG>_LINKER_WRAPPER_FLAG` and
:variable:`CMAKE_<LANG>_LINKER_WRAPPER_FLAG_SEP` variables.
For example, ``"LINKER:-z,defs"`` becomes ``-Xlinker -z -Xlinker defs`` for
``Clang`` and ``-Wl,-z,defs`` for ``GNU GCC``.
2018-11-29 20:27:00 +01:00
The ``LINKER:`` prefix can be specified as part of a ``SHELL:`` prefix
expression.
2020-02-01 23:06:01 +01:00
The ``LINKER:`` prefix supports, as an alternative syntax, specification of
arguments using the ``SHELL:`` prefix and space as separator. The previous
example then becomes ``"LINKER:SHELL:-z defs"``.
2018-11-29 20:27:00 +01:00
.. note::
2020-02-01 23:06:01 +01:00
Specifying the ``SHELL:`` prefix anywhere other than at the beginning of the
2018-11-29 20:27:00 +01:00
``LINKER:`` prefix is not supported.