CMake’s “check_c(xx)_compiler_flag” fails to recognize unsupported “Wno” fails in GCC. The reason is that GCC displays this note:
note: unrecognized command-line option ‘-Wno-unused-command-line-argument’ may have been intended to silence earlier diagnostics
but ONLY if some warning was produced. This is explained in the manpage
When an unrecognized warning option is requested (e.g., -Wunknown-warning), GCC emits a diagnostic stating that the option is not recognized. However, if the -Wno- form is used, the behavior is slightly different: no diagnostic is produced for -Wno-unknown-warning unless other diagnostics are being produced. This allows the use of new -Wno- options with old compilers, but if something goes wrong, the compiler warns that an unrecognized option is present.
I’ve found no way to fix this except for chanching _lang_src in “Internal/CheckCompilerFlag.cmake” so it purposely produces some warning.
Does someone have some other idea or knows what source to use so it produces a warning reliably?