Hybrid-functional calculations of electronic structure and phase stability of MO (M = Zn, Cd, Be, Mg, Ca, Sr, Ba) and related ternary alloy MxZn1−xO