add_dependencies.rst 1005 B

1234567891011121314151617181920212223242526
  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. See the ``DEPENDS`` option of :command:`add_custom_target` and
  17. :command:`add_custom_command` commands for adding file-level
  18. dependencies in custom rules. See the :prop_sf:`OBJECT_DEPENDS`
  19. source file property to add file-level dependencies to object files.