add_dependencies.rst 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. Dependencies added to an :ref:`imported target <Imported Targets>`
  12. or an :ref:`interface library <Interface Libraries>` are followed
  13. transitively in its place since the target itself does not build.
  14. .. versionadded:: 3.3
  15. Allow adding dependencies to interface libraries.
  16. .. versionadded:: 3.8
  17. Dependencies will populate the :prop_tgt:`MANUALLY_ADDED_DEPENDENCIES`
  18. property of ``<target>``.
  19. .. versionchanged:: 3.9
  20. The :ref:`Ninja Generators` use weaker ordering than
  21. other generators in order to improve available concurrency.
  22. They only guarantee that the dependencies' custom commands are
  23. finished before sources in ``<target>`` start compiling; this
  24. ensures generated sources are available.
  25. See Also
  26. ^^^^^^^^
  27. * The ``DEPENDS`` option of :command:`add_custom_target` and
  28. :command:`add_custom_command` commands for adding file-level
  29. dependencies in custom rules.
  30. * The :prop_sf:`OBJECT_DEPENDS` source file property to add
  31. file-level dependencies to object files.