Help with finishing this integral, to obtain the power spectral density of a pure cosine wave I am trying to evaluate the power spectral density $S_{xx}(f)$ of a cosine signal $x(t) = A\cos(2\pi f_0t)$, by starting from its definition for deterministic power signals
$$S_{xx}(f) = \lim_{T\rightarrow\infty}\frac{1}{T}\left|X_{T}(f) \right|^2\;, \tag{1}$$
where $X_T(f)$ is the Fourier transform of a signal $x(t)$ which has been truncated to a time window $T$, given by $$X_T(f) = \int_{-T/2}^{T/2}x(t)\;e^{-2\pi if t}\;dt \;.\tag{2}$$

I know that the answer should be $$S_{xx}(f) = \frac{A^2}{4}\bigg[\delta(f-f_o) + \delta(f+f_o)\bigg]\;,\tag{3}$$ but I am stuck with my working. Can anyone check it so far, and help me fill in the gaps? Perhaps my mathematics is not as good as it ought to be!

\begin{align}
  S_{xx}(f) &amp;= \lim_{T\rightarrow\infty}\frac{1}{T}\left|X_{T}(f) \right|^2\ \tag{4}  \\
            &amp;= \lim_{T\rightarrow\infty}\frac{1}{T}\left[ \int_{-T/2}^{T/2}x(t)\;e^{-2\pi if t}\;dt  \int_{-T/2}^{T/2}x^\ast(t')\;e^{2\pi if t'}\;dt' \right] \tag{5} \\
            &amp;= \lim_{T\rightarrow\infty}\frac{1}{T}\left[ \int_{-T/2}^{T/2}\int_{-T/2}^{T/2} A^2\cos(2\pi f_0t)\cos(2\pi f_0t')\;e^{2\pi if(t'-t)}\;dt \;dt'\right] \tag{6}  \\
            &amp;= \lim_{T\rightarrow\infty}\frac{A^2}{2T}\left[ \int_{-T/2}^{T/2}\int_{-T/2}^{T/2} \Big[\cos\big(2\pi f_0(t+t')\big) + \cos\big(2\pi f_0(t'-t)\big)\Big]\;e^{2\pi if(t'-t)}\;dt \;dt'\right] \tag{7}  
\end{align}
where the last line is obtained by using the product-to-sum identity for cosines. Now, I'm a little stuck. I can make the substitution $\tau = t'-t$, which simplifes the exponential

$$  S_{xx}(f) = \lim_{T\rightarrow\infty}\frac{A^2}{2T}\left[ \int_{-T/2-t}^{T/2-t}\int_{-T/2}^{T/2} \Big[\cos\big(2\pi f_0(2t+\tau)\big) + \cos\big(2\pi f_0\tau\big)\Big]\;e^{2\pi if\tau}\;dt \;d\tau\right] \tag{8}  $$

but now I am not sure how to proceed. I can also replace my cosines with complex exponentials to obtain

$$\lim_{T\rightarrow\infty}\frac{A^2}{4T}\left[ \int_{-T/2}^{T/2}\int_{-T/2}^{T/2} \Big[ e^{2\pi if_0(t+t')} + e^{2\pi if_0(t-t')} +e^{2\pi if_0(t'-t)}+e^{-2\pi if_0(t+t')}    \Big]\;e^{2\pi if(t'-t)}\;dt \;dt'\right]$$

Can someone teach me how to finish this? Ideally I would like it if someone could show me how to evaluate it in terms of $T$, and then show how the $\delta$ functions arise as we finally take the limit $T\rightarrow\infty$.
You don't need to make it so complicated as to use two variables $t$ and $t^\prime$.

\begin{align} X_T(f) &amp;= \int_{-T/2}^{T/2} x(t)\exp(-j2\pi ft)\,\mathrm dt\\
&amp;= \int_{-T/2}^{T/2}\frac{\exp(j2\pi f_0t)+\exp(-j2\pi f_0t)}{2}\exp(-j2\pi ft)\,\mathrm dt\\
&amp;= \frac 12\int_{-T/2}^{T/2} \exp(j2\pi (f_0-f)t)+\exp(-j2\pi (f_0+f)t)\,\mathrm dt\\
&amp;= \frac 12 \left[\frac{\exp(j2\pi (f_0-f)t)}{j2\pi(f_0-f)}~ + ~\frac{\exp(j2\pi (f_0+f)t)}{j2\pi(f_0+f)}\right\vert_{-T/2}^{T/2}\\
&amp;= \frac 12 \left[\frac{\exp(j\pi (f_0-f)T)-\exp(-j\pi (f_0-f)T)}{j2\pi(f_0-f)}\right.\\
&amp;\qquad\qquad + \left.\frac{\exp(j\pi (f_0+f)T)-\exp(-j\pi (f_0+f)T)}{j2\pi(f_0-f)}\right]\\
&amp;= \frac T2 \big(\operatorname{sinc}((f_0+f)T) ~+ ~\operatorname{sinc}((f_0-f)T)\big)\\
&amp;= \frac T2 \big(\operatorname{sinc}((f-f_0)T) ~+ ~\operatorname{sinc}((f+f_0)T)\big).
\end{align}
So we get \begin{align}\frac 1T\big|X_T(f)\big|^2 &amp;= \frac T4 \big(\operatorname{sinc}^2((f-f_0)T) ~+ ~(\operatorname{sinc}^2((f+f_0)T)\\
&amp;\qquad\qquad + 2\operatorname{sinc}((f-f_0)T)(\operatorname{sinc}((f+f_0)T)\big)
\end{align}
In the frequency domain, the two $\operatorname{sinc}^2$ functions are of height $\frac T4$, are centered at $\pm f_0$ with central lobes of width $\frac 2T$ Hz. As $T \to \infty$, the central lobe widths shrink to $0$ and it is straightforward to show that for any value of $f$ other than $\pm f_0$,
$$\lim_{T\to\infty} \frac 1T\big|X_T(f)\big|^2 =0, ~ f \neq \pm f_0.$$
Now, $\frac 1T|X_T(\pm f_0)|^2$ diverges to $\infty$ and with the usual trick of pulling a Dirac delta out of the hat in such cases, we get that it must be that 
$$S_{xx}(f) = \lim_{T\to\infty} \frac 1T|X_T(f)|^2 = \frac 14 \big(\delta(f-f_0) + \delta(f+f_0)\big), ~~ \text{when} ~x(t) = \cos(2\pi f_0 t).$$