CMP0023.rst 1.5 KB

123456789101112131415161718192021222324252627282930313233343536
  1. CMP0023
  2. -------
  3. .. |REMOVED_IN_CMAKE_VERSION| replace:: 4.0
  4. .. include:: include/REMOVED_PROLOGUE.rst
  5. Plain and keyword :command:`target_link_libraries` signatures cannot be mixed.
  6. CMake 2.8.12 introduced the :command:`target_link_libraries` signature using
  7. the ``PUBLIC``, ``PRIVATE``, and ``INTERFACE`` keywords to generalize the
  8. ``LINK_PUBLIC`` and ``LINK_PRIVATE`` keywords introduced in CMake 2.8.7.
  9. Use of signatures with any of these keywords sets the link interface of a
  10. target explicitly, even if empty. This produces confusing behavior
  11. when used in combination with the historical behavior of the plain
  12. :command:`target_link_libraries` signature. For example, consider the code:
  13. .. code-block:: cmake
  14. target_link_libraries(mylib A)
  15. target_link_libraries(mylib PRIVATE B)
  16. After the first line the link interface has not been set explicitly so
  17. CMake would use the link implementation, A, as the link interface.
  18. However, the second line sets the link interface to empty. In order
  19. to avoid this subtle behavior CMake now prefers to disallow mixing the
  20. plain and keyword signatures of :command:`target_link_libraries` for a single
  21. target.
  22. The ``OLD`` behavior for this policy is to allow keyword and plain
  23. :command:`target_link_libraries` signatures to be mixed. The ``NEW`` behavior for
  24. this policy is to not to allow mixing of the keyword and plain
  25. signatures.
  26. .. |INTRODUCED_IN_CMAKE_VERSION| replace:: 2.8.12
  27. .. |WARNED_OR_DID_NOT_WARN| replace:: warned
  28. .. include:: include/REMOVED_EPILOGUE.rst