cmake: Refactored validation of compiler warning flags.