To get Fourier transform,
$$\hat{f}(k) = \frac{1}{2\pi} \int_{\frac{-\pi}{2}}^{\frac{\pi}{2}} \cos(x)e^{-ikx} dx$$
Let $g(x) = 1, f(x) = g(x)cos(x) = g(x)\frac{e^{ix}+e^{-ix}}{2} = \frac{1}{2}[g(x)e^{ix} + g(x)e^{-ix}] = \hat{f}(k) = \frac{1}{2}[\hat{g}(k-1) + \hat{g}(k+1)]$
$$\hat{g}(k) = \frac{1}{2\pi}\int_{\frac{-\pi}{2}}^{\frac{\pi}{2}} e^{-ikx} dx\\=\frac{1}{2\pi}\frac{e^{\frac{-ik\pi}{2}}-e^{\frac{ik\pi}{2}}}{-ik}\\=\frac{1}{2\pi}\frac{e^{\frac{ik\pi}{2}}-e^{\frac{-ik\pi}{2}}}{ik}\\=\frac{1}{k\pi}\sin(\frac{k\pi}{2})$$
Then, $$\hat{f}(k) = \frac{1}{2}[\hat{g}(k-1) + \hat{g}(k+1)]\\=\frac{1}{2}[\frac{1}{(k-1)\pi}\sin(\frac{(k-1)\pi}{2}) + \frac{1}{(k+1)\pi}\sin(\frac{(k+1)\pi}{2})]\\=\frac{1}{2}[\frac{1}{(k-1)\pi}\sin(\frac{(k\pi-\pi)}{2}) + \frac{1}{(k+1)\pi}\sin(\frac{(k\pi+\pi)}{2}]\\=\frac{1}{2}[\frac{1}{(1-k)\pi}\cos(\frac{k\pi}{2})+\frac{1}{(1+k)\pi}\cos(\frac{k\pi}{2})]\\=\frac{2}{2\pi(1-k^2)}\cos(\frac{k\pi}{2}) \\= \frac{1}{\pi(1-k^2)}\cos(\frac{k\pi}{2})$$
Hence, we write $f(x)$ as a Fourier integral.
$$f(x) = \int_{-\infty}^{\infty} \frac{1}{\pi(1-k^2)}\cos(\frac{k\pi}{2})e^{ikx} dk$$