target_compile_features() uses incorrect C++ version
I have realized that my C++ primesieve project (https://github.com/kimwalisch/primesieve) is compiled using -std=gnu++11 with GCC 7.3 and CMake 3.10 (on Ubuntu 18.10 x64) even though the default C++ version used by GCC 7.3 is C++14 as checked below:
$ g++ -dM -E -x c++ /dev/null | grep -F __cplusplus #define __cplusplus 201402L
Note that I have not set CXX_STANDARD manually in my CMakeLists.txt so I was expecting that my project would be compiled either with -std=gnu++14 or without any C++ version flag. I spent some time investigating where the -std=gnu++11 flag comes from and I found that it is related to the use of target_compile_features():
target_compile_features(primesieve PRIVATE cxx_auto_type)
This code tells the compiler that my program uses features from C++11 and that the compiler should enable C++11 if the default C++ version of the compiler is e.g. C++98. I would however expect that if the default C++ version of the compiler is > C++11 CMake would not add -std=gnu++11 to the compiler flags.
For me this is a CMake bug.