CXX_STANDARD.rst 1.3 KB

123456789101112131415161718192021222324252627282930313233
  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``, ``14``, and ``17``.
  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. Additionally, the :prop_tgt:`CXX_EXTENSIONS` target property may be used to
  19. control whether compiler-specific extensions are enabled on a per-target basis.
  20. See the :manual:`cmake-compile-features(7)` manual for information on
  21. compile features and a list of supported compilers.
  22. This property is initialized by the value of
  23. the :variable:`CMAKE_CXX_STANDARD` variable if it is set when a target
  24. is created.