target_compile_options.rst 1.1 KB

123456789101112131415161718192021222324252627
  1. target_compile_options
  2. ----------------------
  3. Add compile options to a target.
  4. ::
  5. target_compile_options(<target> [BEFORE] <INTERFACE|PUBLIC|PRIVATE> [items1...]
  6. [<INTERFACE|PUBLIC|PRIVATE> [items2...] ...])
  7. Specify compile options to use when compiling a given target. The
  8. named <target> must have been created by a command such as
  9. add_executable or add_library and must not be an IMPORTED target. If
  10. BEFORE is specified, the content will be prepended to the property
  11. instead of being appended.
  12. The INTERFACE, PUBLIC and PRIVATE keywords are required to specify the
  13. scope of the following arguments. PRIVATE and PUBLIC items will
  14. populate the COMPILE_OPTIONS property of <target>. PUBLIC and
  15. INTERFACE items will populate the INTERFACE_COMPILE_OPTIONS property
  16. of <target>. The following arguments specify compile opitions.
  17. Repeated calls for the same <target> append items in the order called.
  18. Arguments to target_compile_options may use "generator expressions"
  19. with the syntax "$<...>".
  20. See the :manual:`cmake-generator-expressions(7)` manual for available
  21. expressions.