# CMake does not set the compiler option -std to gnu17 or c++17 although I set the target\_compile\_features to cxx\_std\_17

**URL:** https://discourse.cmake.org/t/cmake-does-not-set-the-compiler-option-std-to-gnu17-or-c-17-although-i-set-the-target-compile-features-to-cxx-std-17/3299
**Category:** Usage
**Tags:** comp:gcc
**Created:** [May 12, 2021, 10:44am UTC](https://discourse.cmake.org/t/cmake-does-not-set-the-compiler-option-std-to-gnu17-or-c-17-although-i-set-the-target-compile-features-to-cxx-std-17/3299 "2021-05-12T10:44:30Z")
**Posts on this page:** 1
**Showing post:** 8

<div class="post-metadata">

### Author: ![brad.king](https://discourse.cmake.org/user_avatar/discourse.cmake.org/brad.king/32/11_2.png) [@brad.king](https://discourse.cmake.org/u/brad.king)
#### Post date: [May 13, 2021, 12:42pm UTC](https://discourse.cmake.org/t/cmake-does-not-set-the-compiler-option-std-to-gnu17-or-c-17-although-i-set-the-target-compile-features-to-cxx-std-17/3299/8 "2021-05-13T12:42:45Z")

</div>

This is working as designed. The `cxx_std_17` feature is [documented here](https://cmake.org/cmake/help/v3.20/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.html#high-level-meta-features-indicating-c-standard-support). It does not mean “pass -std=c++17”. It means “run the compiler in a mode that supports C++17”. If the default compiler mode supports C++17, no flag is added.

gcc 11 defaults to C++17, and so does not need any `-std=` flag to satisfy `cxx_std_17`. On Fedora 34:

```auto
$ g++ --version
g++ (GCC) 11.1.1 20210428 (Red Hat 11.1.1-1)
$ g++ -x c++ /dev/null -E -dM | grep __cplusplus
#define __cplusplus 201703L

```

---

_[View the full topic](https://discourse.cmake.org/t/cmake-does-not-set-the-compiler-option-std-to-gnu17-or-c-17-although-i-set-the-target-compile-features-to-cxx-std-17/3299)._
