  For every cube $Q \subset \mathbb{R}^n$ we let $X_Q$ be a quasi-Banach
function space over $Q$ such that $\|\chi_Q\|_{X_Q} \simeq 1$, and for $X=
\{X_Q\}$ define \begin{align*} \|f\|_{\mathrm{BMO}_X} &:=\sup_Q
\,\|f-{\textstyle\frac{1}{|Q|}\int_Qf} \|_{X_Q},\\ \|f\|_{\mathrm{BMO}_X^*}
&:=\sup_Q \,\inf_c\, \|f-c\|_{X_Q}. \end{align*} We study necessary and
sufficient conditions on $X$ such that $$ \mathrm{BMO} = \mathrm{BMO}_X =
\mathrm{BMO}_{X}^*. $$ In particular, we give a full characterization of the
embedding $\mathrm{BMO} \hookrightarrow \mathrm{BMO}_X$ in terms of so-called
sparse collections of cubes and we give easily checkable and rather weak
sufficient conditions for the embedding $\mathrm{BMO}_X^* \hookrightarrow
\mathrm{BMO}$. Our main theorems recover and improve all previously known
results in this area.
