Add CMAKE_REQUIRED_FLAGS in flag tests.