LINK_OPTIONS: Add support of "LINKER:" prefix

This commit is contained in:
Marc Chevrier
2018-04-30 18:56:25 +02:00
parent c1f5a44b28
commit 66ea1a3795
51 changed files with 423 additions and 42 deletions

View File

@@ -0,0 +1,10 @@
To pass options to the linker tool, each compiler driver has is own syntax.
The ``LINKER:`` prefix can be used to specify, in a portable way, options
to pass to the linker tool. The ``LINKER:`` prefix is replaced by the required
driver option and the rest of the option string defines linker arguments using
``,`` as separator. These arguments will be formatted according to the
: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``.

View File

@@ -7,12 +7,12 @@ Adds options to the link of targets.
add_link_options(<option> ...)
Adds options to the linker command line for targets in the current
directory and below that are added after this command is invoked.
See documentation of the :prop_dir:`directory <LINK_OPTIONS>` and
Adds options to the link step for targets in the current directory and below
that are added after this command is invoked. See documentation of the
:prop_dir:`directory <LINK_OPTIONS>` and
:prop_tgt:`target <LINK_OPTIONS>` ``LINK_OPTIONS`` properties.
This command can be used to add any options, but alternative command
This command can be used to add any options, but alternative commands
exist to add libraries (:command:`target_link_libraries` or
:command:`link_libraries`).
@@ -21,4 +21,6 @@ the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)`
manual for available expressions. See the :manual:`cmake-buildsystem(7)`
manual for more on defining buildsystem properties.
.. include:: LINK_OPTIONS_LINKER.txt
.. include:: OPTIONS_SHELL.txt

View File

@@ -29,7 +29,7 @@ items will populate the :prop_tgt:`LINK_OPTIONS` property of
``<target>``. ``PUBLIC`` and ``INTERFACE`` items will populate the
:prop_tgt:`INTERFACE_LINK_OPTIONS` property of ``<target>``.
(:ref:`IMPORTED targets <Imported Targets>` only support ``INTERFACE`` items.)
The following arguments specify compile options. Repeated calls for the same
The following arguments specify link options. Repeated calls for the same
``<target>`` append items in the order called.
Arguments to ``target_link_options`` may use "generator expressions"
@@ -37,4 +37,6 @@ with the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)`
manual for available expressions. See the :manual:`cmake-buildsystem(7)`
manual for more on defining buildsystem properties.
.. include:: LINK_OPTIONS_LINKER.txt
.. include:: OPTIONS_SHELL.txt