target_sources.rst 1.2 KB

1234567891011121314151617181920212223242526272829
  1. target_sources
  2. --------------
  3. Add sources to a target.
  4. ::
  5. target_sources(<target>
  6. <INTERFACE|PUBLIC|PRIVATE> [items1...]
  7. [<INTERFACE|PUBLIC|PRIVATE> [items2...] ...])
  8. Specify sources to use when compiling a given target. The
  9. named ``<target>`` must have been created by a command such as
  10. :command:`add_executable` or :command:`add_library` and must not be an
  11. :ref:`ALIAS target <Alias Targets>`.
  12. The ``INTERFACE``, ``PUBLIC`` and ``PRIVATE`` keywords are required to
  13. specify the scope of the following arguments. ``PRIVATE`` and ``PUBLIC``
  14. items will populate the :prop_tgt:`SOURCES` property of
  15. ``<target>``. ``PUBLIC`` and ``INTERFACE`` items will populate the
  16. :prop_tgt:`INTERFACE_SOURCES` property of ``<target>``.
  17. (:ref:`IMPORTED targets <Imported Targets>` only support ``INTERFACE`` items.)
  18. The following arguments specify sources. Repeated calls for the same
  19. ``<target>`` append items in the order called.
  20. Arguments to ``target_sources`` may use "generator expressions"
  21. with the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)`
  22. manual for available expressions. See the :manual:`cmake-buildsystem(7)`
  23. manual for more on defining buildsystem properties.