Context : The way angular momentum is built up in stars during their formation process may have an impact on their further evolution . Aims : 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 ) . Methods : Computation begins from a hydrostatic core on the Hayashi line of 0.7 M _ { \odot } 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.5 \times 10 ^ { -5 } and 1.7 \times 10 ^ { -3 } M _ { \odot } yr ^ { -1 } . 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 M _ { \odot } . Results : 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 . Typically , the 6 M _ { \odot } model has a core that rotates 50 % faster than the surface on the ZAMS . The degree of differential rotation on the ZAMS decreases when the mass increases ( for a fixed value of v _ { ZAMS } / v _ { crit } ) . The MS evolution of our models with a pre-MS accreting phase show no significant differences with respect to those of corresponding models computed from the ZAMS with an initial solid-body rotation . Interestingly , for masses on the ZAMS larger than 8 M _ { \odot } , there exists a maximum surface velocity that can be reached through the present scenario of formation . Typically , for 14 M _ { \odot } 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 M _ { \odot } , there is no restriction and the whole domain of velocities , up to the critical one , can be reached . Conclusions :