We report in the present paper ab initio calculations of the structural, electronic and optical properties of zinc blende quaternary alloys CdxMg(1-x)TeyS(1-y) lattice matched to CdX (X = S, Te) exploring the density functional method within the generalized gradient approximation (GGA). From the obtained values of the ground state energy, we have determined the structural parameters and the band gap energies. We found an underestimation of the gap energies obtained for both (GGA-PBE) and the Modified Becke-Johnson exchange potential (TB-mbJ) approximations for the CdS, CdTe, MgS, and MgTe. Even though mbJ significantly corrects the energy gaps, it is no longer valid to properly reproduce the exchange-correlation potential. Consequently, we tend to use the corrective term ΔE to exploit it to enhance the electronic band structures.Moreover, we have reported the concentration depending on the refractive index and the dielectric function using (mbJ). The critical thickness, for which the lattice of the CdxMg(1-x)TeyS(1-y) matches CdS and CdTe, respectively, are determined. The results show that for all Cd and Te incorporated amounts, the CdxMg(1-x)TeyS(1-y) lattice matched to CdX (X = S, Te) substrate alloys exhibits a semiconducting behavior with a small lattice mismatching ratio which might make CdxMg(1-x)TeyS(1-y)/CdX materials promising and useful for optoelectronic applications.