add_dependencies.rst 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. add_dependencies
  2. ----------------
  3. Add a dependency between top-level targets.
  4. .. code-block:: cmake
  5. add_dependencies(<target> <target-dependency>...)
  6. Makes a top-level ``<target>`` depend on other top-level targets to
  7. ensure that they build before ``<target>`` does. A top-level target
  8. is one created by one of the :command:`add_executable`,
  9. :command:`add_library`, or :command:`add_custom_target` commands
  10. (but not targets generated by CMake like ``install``).
  11. At least one ``<target-dependency>`` must be given.
  12. Dependencies added to an :ref:`imported target <Imported Targets>`
  13. or an :ref:`interface library <Interface Libraries>` are followed
  14. transitively in its place since the target itself does not build.
  15. .. versionadded:: 3.3
  16. Allow adding dependencies to interface libraries.
  17. .. versionadded:: 3.8
  18. Dependencies will populate the :prop_tgt:`MANUALLY_ADDED_DEPENDENCIES`
  19. property of ``<target>``.
  20. .. versionchanged:: 3.9
  21. The :ref:`Ninja Generators` use weaker ordering than
  22. other generators in order to improve available concurrency.
  23. They only guarantee that the dependencies' custom commands are
  24. finished before sources in ``<target>`` start compiling; this
  25. ensures generated sources are available.
  26. See Also
  27. ^^^^^^^^
  28. * The ``DEPENDS`` option of :command:`add_custom_target` and
  29. :command:`add_custom_command` commands for adding file-level
  30. dependencies in custom rules.
  31. * The :prop_sf:`OBJECT_DEPENDS` source file property to add
  32. file-level dependencies to object files.