LINK_OPTIONS_LINKER.txt 1.1 KB

12345678910111213141516171819202122232425
  1. Handling Compiler Driver Differences
  2. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  3. To pass options to the linker tool, each compiler driver has its own syntax.
  4. The ``LINKER:`` prefix and ``,`` separator can be used to specify, in a portable
  5. way, options to pass to the linker tool. ``LINKER:`` is replaced by the
  6. appropriate driver option and ``,`` by the appropriate driver separator.
  7. The driver prefix and driver separator are given by the values of the
  8. :variable:`CMAKE_<LANG>_LINKER_WRAPPER_FLAG` and
  9. :variable:`CMAKE_<LANG>_LINKER_WRAPPER_FLAG_SEP` variables.
  10. For example, ``"LINKER:-z,defs"`` becomes ``-Xlinker -z -Xlinker defs`` for
  11. ``Clang`` and ``-Wl,-z,defs`` for ``GNU GCC``.
  12. The ``LINKER:`` prefix can be specified as part of a ``SHELL:`` prefix
  13. expression.
  14. The ``LINKER:`` prefix supports, as an alternative syntax, specification of
  15. arguments using the ``SHELL:`` prefix and space as separator. The previous
  16. example then becomes ``"LINKER:SHELL:-z defs"``.
  17. .. note::
  18. Specifying the ``SHELL:`` prefix anywhere other than at the beginning of the
  19. ``LINKER:`` prefix is not supported.