A simple least-squares fitting-based method is described for the determination of strain profiles in epitaxial films using high-resolution X-ray diffraction. The method is model-independent,i.e.it does not require any `guess' model for the shape of the strain profile. The shape of the vertical displacement profile is modelled using the versatile cubicB-spline functions, which puts smoothness and curvature constraints on the fitting procedure. The effect of a coherently diffracting substrate is taken into account as well as the effects of film thickness fluctuations. The model is applied to the determination of strain profiles in SmNiO3films epitaxically grown on SrTiO3(001) substrates. The shape of the retrieved strain profile is discussed in terms of oxygen vacancies.