The $p_\text{T}$-differential inclusive production cross sections of the prompt charmed mesons $D^0$, $D^+$, and $D^{\ast +}$ in the rapidity range $|y|<0.5$ were measured in proton-proton collisions at $\sqrt{s}=7$ TeV at the LHC using the ALICE detector. Reconstructing the decays $D^0 \to K^-\pi^+$, $D^+\to K^-\pi^+\pi^+$, $D^{\ast +} \to D^0\pi^+$, and their charge conjugates, about 8,400 $D^0$, 2,900 $D^+$, and 2,600 $D^{\ast +}$ mesons with $1 < p_\text{T} < 24$ GeV/$c$ were counted, after selection cuts, in a data sample of 3.14$\times 10^8$ events collected with a minimum-bias trigger (integrated luminosity $L_\text{int} = 5$/nb). The results are described within uncertainties by predictions based on perturbative QCD.