A generalization of the Cai--Galloway splitting theorem to smooth metric measure spaces