The production cross sections of the prompt charmed mesons D$^0$, D$^+$, D$^*+$ and D$_s^+$ were measured at mid-rapidity in proton-proton collisions at a centre-of-mass energy $\sqrt{s}=7$ TeV with the ALICE detector at the Large Hadron Collider (LHC). D mesons were reconstructed from their decays ${\rm D}^0\rightarrow{\rm K}^-π^+$, ${\rm D}^+\rightarrow{\rm K}^-π^+π^+$, ${\rm D}^{*+}\rightarrow{\rm D}^0π^+$, ${\rm D}_s^+→ϕπ^+→ {\rm K}^-{\rm K}^+π^+$, and their charge conjugates. With respect to previous measurements in the same rapidity region, the coverage in transverse momentum ($p_{\rm T}$) is extended and the uncertainties are reduced by a factor of about two. The accuracy on the estimated total $c{\overline c}$ production cross section is likewise improved. The measured $p_{\rm T}$-differential cross sections are compared with the results of three perturbative QCD calculations.