  New molecular line lists for calcium monohydride ($^{40}$Ca$^{1}$H) and
magnesium monohydride ($^{24}$Mg$^{1}$H) and its minor isotopologues
($^{25}$Mg$^{1}$H and $^{26}$Mg$^{1}$H) are presented. The
rotation-vibration-electronic (rovibronic) line lists, named \texttt{XAB},
consider transitions involving the \X, \A, and \BBp\ electronic states in the
0--30\,000~cm$^{-1}$ region (wavelengths $\lambda > 0.33$~$\mu$m) and are
suitable for temperatures up to 5000 K. A comprehensive analysis of the
published spectroscopic literature on CaH and MgH is used to obtain new
extensive datasets of accurate rovibronic energy levels with measurement
uncertainties and consistent quantum number labelling. These datasets are used
to produce new spectroscopic models for CaH and MgH, composed of newly
empirically-refined potential energy curves and couplings in/between the
different electronic states (e.g.\ spin-orbit, electronic angular momentum,
Born-Oppenheimer breakdown, spin-rotation, $\Lambda$-doubling) and previously
published \textit{ab initio} transition dipole moment curves. Along with
Einstein $A$ coefficients, state lifetimes and Land\'e $g$-factors are
provided, the latter being particularly useful as CaH and MgH can be used to
probe stellar magnetic fields. Computed energy levels have been replaced with
the more accurate empirical values (if available) when post-processing the line
lists, thus tailoring the line lists to high resolution applications. The
\texttt{XAB} line lists are available from the ExoMol database at
http://www.exomol.com and the CDS astronomical database.
