The way angular momentum is built up in stars during their formation process may have an impact on their further evolution. In the frame of the cold disc accretion scenario, we study for the first time how angular momentum builds up inside the star during its formation and what are the consequences for its evolution on the main sequence (MS). Computation begins from a hydrostatic core on the Hayashi line of 0.7 Msol at solar metallicity (Z=0.014) rotating as a solid body. Accretion rates depending on the luminosity of the accreting object are considered varying between 1.5e-5 and 1.7e-3 Msol/yr. The accreted matter is assumed to have an angular velocity equal to that of the outer layer of the accreting star. Models are computed for a mass-range on the zero-age main sequence (ZAMS) between 2 and 22 Msol. We study how the internal and surface velocities vary as a function of time during the accretion phase and the evolution towards the ZAMS. Stellar models, whose evolution has been followed along the pre-MS phase, are found to exhibit a shallow gradient of angular velocity on the ZAMS. Interestingly, for masses on the ZAMS larger than 8 Msol, there exists a maximum surface velocity that can be reached through the present scenario of formation. Typically, for 14 Msol models, only stars with surface velocities on the ZAMS lower than about 45% of the critical velocity can be formed. To reach higher velocities would require to start from cores rotating above the critical limit. We find that this upper velocity limit is smaller for higher masses. In contrast, below 8 Msol, there is no restriction and the whole domain of velocities, up to the critical one, can be reached.