C_STANDARD.rst 1.2 KB

12345678910111213141516171819202122232425262728293031
  1. C_STANDARD
  2. ----------
  3. The C standard whose features are requested to build this target.
  4. This property specifies the C standard whose features are requested
  5. to build this target. For some compilers, this results in adding a
  6. flag such as ``-std=gnu11`` to the compile line. For compilers that
  7. have no notion of a standard level, such as MSVC, this has no effect.
  8. Supported values are ``90``, ``99`` and ``11``.
  9. If the value requested does not result in a compile flag being added for
  10. the compiler in use, a previous standard flag will be added instead. This
  11. means that using:
  12. .. code-block:: cmake
  13. set_property(TARGET tgt PROPERTY C_STANDARD 11)
  14. with a compiler which does not support ``-std=gnu11`` or an equivalent
  15. flag will not result in an error or warning, but will instead add the
  16. ``-std=gnu99`` or ``-std=gnu90`` flag if supported. This "decay" behavior may
  17. be controlled with the :prop_tgt:`C_STANDARD_REQUIRED` target property.
  18. See the :manual:`cmake-compile-features(7)` manual for information on
  19. compile features and a list of supported compilers.
  20. This property is initialized by the value of
  21. the :variable:`CMAKE_C_STANDARD` variable if it is set when a target
  22. is created.