In this paper, we generalize Szegő's theorem for orthogonal polynomials on the real line to infinite gap sets of Parreau–Widom type. This notion includes Cantor sets of positive measure. The Szegő condition involves the equilibrium measure which in turn is absolutely continuous. Our approach builds on a canonical factorization of the M-function and the covering space formalism of Sodin–Yuditskii.