LINK_LIBRARIES_LINKER.rst 1.0 KB

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