add_dependencies.rst 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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. .. versionchanged:: 3.9
  17. The :ref:`Ninja Generators` use weaker ordering than
  18. other generators in order to improve available concurrency.
  19. They only guarantee that the dependencies' custom commands are
  20. finished before sources in ``<target>`` start compiling; this
  21. ensures generated sources are available.
  22. See Also
  23. ^^^^^^^^
  24. * The ``DEPENDS`` option of :command:`add_custom_target` and
  25. :command:`add_custom_command` commands for adding file-level
  26. dependencies in custom rules.
  27. * The :prop_sf:`OBJECT_DEPENDS` source file property to add
  28. file-level dependencies to object files.