Cluster perturbation theory is a technique for calculating the spectral weight of Hubbard models of strongly correlated electrons, which combines exact diagonalizations on small clusters with strongcoupling perturbation theory at leading order. It is exact in both the strong-and weak-coupling limits and provides a good approximation to the spectral function at any wavevector. Following the paper by Sénéchal et al. (Phys. Rev. Lett. 84, 522 (2000)), we provide a more complete description and derivation of the method. We illustrate some of its capabilities, in particular regarding the effect of doping, the calculation of ground state energy and double occupancy, the disappearance of the Fermi surface in the t − t ′ Hubbard model, and so on. The method is applicable to any model with on-site repulsion only.