CMake does not set the compiler option -std to gnu17 or c++17 although I set the target_compile_features to cxx_std_17

This is working as designed. The cxx_std_17 feature is documented here. 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:

$ 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
1 Like