CXX_STANDARD.rst 1.2 KB

12345678910111213141516171819202122232425262728293031
  1. CXX_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=gnu++11`` 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 ``98``, ``11`` and ``14``.
  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 CXX_STANDARD 11)
  14. with a compiler which does not support ``-std=gnu++11`` or an equivalent
  15. flag will not result in an error or warning, but will instead add the
  16. ``-std=gnu++98`` flag if supported. This "decay" behavior may be controlled
  17. with the :prop_tgt:`CXX_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_CXX_STANDARD` variable if it is set when a target
  22. is created.