cmake: use separate temporary variable names in compiler flag tests

Redmine: refs #2442