CMake should take the value of CMAKE_<lang>_FLAGS_INIT into account during compiler detection
To detect the compiler being used, CMake will attempt to compile a small test program, using the flags in
CMAKE_<lang>_FLAGS for this purpose. However, when using a toolchain file written according to the guidance in the CMake documentation, the toolchain file will have set
CMAKE_<lang>_FLAGS will not be defined yet. While it is of course possible to set
CMAKE_<lang>_FLAGS directly in the toolchain file.
I ran into this issue with Intel icc 19.0.2 with a custom gcc 5.5 toolchain specified via icc's '-gnu-prefix' option. Without this option, icc uses the default gcc installed on the host machine (in my case, gcc 7.4.0). CMake then detects that C++14 is the default C++ standard supported, and thus doesn't add '-std=gnu++11' to the command line for targets requiring C++11. Unfortunately, when icc 19.0.2 is used with a gcc 5.5 toolchain, the default C++ standard supported is prior to C++11 and the project does not compile.