8ae6c57e438f7df113f80f69991025f9a2ab179e
[platform/upstream/cmake.git] / Help / variable / LINK_LIBRARY_PREDEFINED_FEATURES.txt
1 ``DEFAULT``
2   This feature corresponds to standard linking, essentially equivalent to
3   using no feature at all.  It is typically only used with the
4   :prop_tgt:`LINK_LIBRARY_OVERRIDE` and
5   :prop_tgt:`LINK_LIBRARY_OVERRIDE_<LIBRARY>` target properties.
6
7 ``WHOLE_ARCHIVE``
8   Force inclusion of all members of a static library.  This feature is only
9   supported for the following platforms, with limitations as noted:
10
11   * Linux.
12   * All BSD variants.
13   * SunOS.
14   * All Apple variants.  The library must be specified as a CMake target name,
15     a library file name (such as ``libfoo.a``), or a library file path (such as
16     ``/path/to/libfoo.a``).  Due to a limitation of the Apple linker, it
17     cannot be specified as a plain library name like ``foo``, where ``foo``
18     is not a CMake target.
19   * Windows.  When using a MSVC or MSVC-like toolchain, the MSVC version must
20     be greater than 1900.
21   * Cygwin.
22   * MSYS.
23
24 ``FRAMEWORK``
25   This option tells the linker to search for the specified framework using
26   the ``-framework`` linker option.  It can only be used on Apple platforms,
27   and only with a linker that understands the option used (i.e. the linker
28   provided with Xcode, or one compatible with it).
29
30   The framework can be specified as a CMake framework target, a bare framework
31   name, or a file path.  If a target is given, that target must have the
32   :prop_tgt:`FRAMEWORK` target property set to true.  For a file path, if it
33   contains a directory part, that directory will be added as a framework
34   search path.
35
36   .. code-block:: cmake
37
38     add_library(lib SHARED ...)
39     target_link_libraries(lib PRIVATE "$<LINK_LIBRARY:FRAMEWORK,/path/to/my_framework>")
40
41     # The constructed linker command line will contain:
42     #   -F/path/to -framework my_framework
43
44   File paths must conform to one of the following patterns (``*`` is a
45   wildcard, and optional parts are shown as ``[...]``):
46
47      * ``[/path/to/]FwName[.framework]``
48      * ``[/path/to/]FwName.framework/FwName``
49      * ``[/path/to/]FwName.framework/Versions/*/FwName``
50
51   Note that CMake recognizes and automatically handles framework targets,
52   even without using the ``$<LINK_LIBRARY:FRAMEWORK,...>`` expression.
53   The generator expression can still be used with a CMake target if the
54   project wants to be explicit about it, but it is not required to do so.
55   The linker command line may have some differences between using the
56   generator expression or not, but the final result should be the same.
57   On the other hand, if a file path is given, CMake will recognize some paths
58   automatically, but not all cases.  The project may want to use
59   ``$<LINK_LIBRARY:FRAMEWORK,...>`` for file paths so that the expected
60   behavior is clear.
61
62 ``NEEDED_FRAMEWORK``
63   This is similar to the ``FRAMEWORK`` feature, except it forces the linker
64   to link with the framework even if no symbols are used from it.  It uses
65   the ``-needed_framework`` option and has the same linker constraints as
66   ``FRAMEWORK``.
67
68 ``REEXPORT_FRAMEWORK``
69   This is similar to the ``FRAMEWORK`` feature, except it tells the linker
70   that the framework should be available to clients linking to the library
71   being created.  It uses the ``-reexport_framework`` option and has the
72   same linker constraints as ``FRAMEWORK``.
73
74 ``WEAK_FRAMEWORK``
75   This is similar to the ``FRAMEWORK`` feature, except it forces the linker
76   to mark the framework and all references to it as weak imports.  It uses
77   the ``-weak_framework`` option and has the same linker constraints as
78   ``FRAMEWORK``.
79
80 ``NEEDED_LIBRARY``
81   This is similar to the ``NEEDED_FRAMEWORK`` feature, except it is for use
82   with non-framework targets or libraries (Apple platforms only).
83   It uses the ``-needed_library`` or ``-needed-l`` option as appropriate,
84   and has the same linker constraints as ``NEEDED_FRAMEWORK``.
85
86 ``REEXPORT_LIBRARY``
87   This is similar to the ``REEXPORT_FRAMEWORK`` feature,  except it is for use
88   with non-framework targets or libraries (Apple platforms only).
89   It uses the ``-reexport_library`` or ``-reexport-l`` option as appropriate,
90   and has the same linker constraints as ``REEXPORT_FRAMEWORK``.
91
92 ``WEAK_LIBRARY``
93   This is similar to the ``WEAK_FRAMEWORK`` feature, except it is for use
94   with non-framework targets or libraries (Apple platforms only).
95   It uses the ``-weak_library`` or ``-weak-l`` option as appropriate,
96   and has the same linker constraints as ``WEAK_FRAMEWORK``.