cmake: Refactored validation of compiler warning flags.

Only refactoring.
Resultant warning flags are same with before.