Ground-state properties and excitation energies of cubic SrO and MgO