COMPILE_OPTIONS.rst 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. COMPILE_OPTIONS
  2. ---------------
  3. .. versionadded:: 3.11
  4. List of additional options to pass to the compiler.
  5. This property holds a :ref:`semicolon-separated list <CMake Language Lists>`
  6. of options and will be added to the list of compile flags when this source
  7. file builds. The options will be added after target-wide options.
  8. Contents of ``COMPILE_OPTIONS`` may use "generator expressions" with the
  9. syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)` manual
  10. for available expressions. However, :generator:`Xcode`
  11. does not support per-config per-source settings, so expressions
  12. that depend on the build configuration are not allowed with that
  13. generator.
  14. Usage example:
  15. .. code-block:: cmake
  16. set_source_files_properties(foo.cpp PROPERTIES COMPILE_OPTIONS "-Wno-unused-parameter;-Wno-missing-field-initializer")
  17. Related properties:
  18. * Prefer this property over :prop_sf:`COMPILE_FLAGS`.
  19. * Use :prop_sf:`COMPILE_DEFINITIONS` to pass additional preprocessor definitions.
  20. * Use :prop_sf:`INCLUDE_DIRECTORIES` to pass additional include directories.
  21. Related commands:
  22. * :command:`add_compile_options` for directory-wide settings
  23. * :command:`target_compile_options` for target-specific settings