I’ve got an old project that uses the clang /Ox flag for certain configurations on Windows. According to the online clang documentation (Clang Compiler User’s Manual — Clang 11 documentation),
this flag is deprecated. However, clang doesn’t produce any warnings or errors when this flag is used.
I would like to configure CMake to warn me about “bad” compiler flags (on both windows and Linux and with clang and gcc), so /Ox for clang (which is deprecated), /Og on clang (which does nothing), and so on. The only way I can think of to do this is to trawl through the clang and gcc documentation, draw up my own blacklist of “bad” flags, and compare that against CMAKE_CXX_FLAGS and friends. Is there a better way?
Disclaimer: It’s really hard to google for this - mostly I just get advice about how to check for deprecated C++ features, which isn’t quite what I’m interested in.