CMP0079.rst 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. CMP0079
  2. -------
  3. :command:`target_link_libraries` allows use with targets in other directories.
  4. Prior to CMake 3.13 the :command:`target_link_libraries` command did not
  5. accept targets not created in the calling directory as its first argument
  6. for calls that update the :prop_tgt:`LINK_LIBRARIES` of the target itself.
  7. It did accidentally accept targets from other directories on calls that
  8. only update the :prop_tgt:`INTERFACE_LINK_LIBRARIES`, but would simply
  9. add entries to the property as if the call were made in the original
  10. directory. Thus link interface libraries specified this way were always
  11. looked up by generators in the scope of the original target rather than
  12. in the scope that called :command:`target_link_libraries`.
  13. CMake 3.13 now allows the :command:`target_link_libraries` command to
  14. be called from any directory to add link dependencies and link interface
  15. libraries to targets created in other directories. The entries are added
  16. to :prop_tgt:`LINK_LIBRARIES` and :prop_tgt:`INTERFACE_LINK_LIBRARIES`
  17. using a special (internal) suffix to tell the generators to look up the
  18. names in the calling scope rather than the scope that created the target.
  19. This policy provides compatibility with projects that already use
  20. :command:`target_link_libraries` with the ``INTERFACE`` keyword
  21. on a target in another directory to add :prop_tgt:`INTERFACE_LINK_LIBRARIES`
  22. entries to be looked up in the target's directory. Such projects should
  23. be updated to be aware of the new scoping rules in that case.
  24. The ``OLD`` behavior of this policy is to disallow
  25. :command:`target_link_libraries` calls naming targets from another directory
  26. except in the previously accidentally allowed case of using the ``INTERFACE``
  27. keyword only. The ``NEW`` behavior of this policy is to allow all such
  28. calls but use the new scoping rules.
  29. This policy was introduced in CMake version 3.13. CMake version
  30. |release| warns when the policy is not set and uses ``OLD`` behavior.
  31. Use the :command:`cmake_policy` command to set it to ``OLD`` or ``NEW``
  32. explicitly.
  33. .. include:: DEPRECATED.txt