Abreg: We investigate the impact of polarized foreground emission on the performances of future CMB experiments in measuring the tensor-to-scalar ratio r. We design a component separation pipeline, based on the Smica method, aimed at estimating r and the foreground contamination from the data with no prior assumption on the frequency dependence or spatial distribution of the foregrounds. We derive error bars accounting for the uncertainty on foreground contribution. We use the current knowledge of galactic and extra-galactic foregrounds as implemented in the Planck Sky Model (PSM), to build simulations of the sky emission for various experimental setups. Our method, permits us to detect r = 0.1 at more than 3 sigma from B-modes only with Planck data, and r = 0.001 at 6 sigma for the most ambitious designs of the future EPIC probe. We find that all-sky experiments permit a proper measurement of the reionization bump despite the large scale foreground emission and are nearly insensitive to contamination from point sources and lensing if their statistical contribution can be modelled accurately. Investigating the observation of a small but clean part of the sky, we show that diffuse foregrounds remain a concern for a sensitive ground-based experiment with a limited frequency coverage when measuring r < 0.1, but are dealt with efficiently by a deep field space mission which is in return quite sensitive to lensing. Our results do not significantly depend on the overall level and frequency dependence of the diffused foreground model.