Let $f(x)=\cos x$ for $-\frac{\pi}{2}<x<\frac{\pi}{2}$, and $0$ everywhere else.
Then $\tilde f(\omega)$ becomes $$\int_{-\frac{\pi}{2}}^{\frac{\pi}{2}} \cos (x) e^{-i \omega x} dx=\frac{2\cos(\frac{\pi}{2}\omega)}{1-\omega^2}$$
There are just some confusion I got for this kind of functions
If we consider the Fourier transform of $f''(x)=- \cos x$ for $-\frac{\pi}{2}<x<\frac{\pi}{2}$, and $0$ everywhere else. Assuming we can even take the derivatives of such function (defined only on an open interval) to begin with, the Fourier transform of $f''$ becomes $$\frac{-\omega^22\cos(\frac{\pi}{2}\omega)}{1-\omega^2}$$ So the Fourier transform of $\cos x$ differs by a factor of $\omega^2$, but we have defined our Fourier transform to be unique? Are those 2 functions the same after inverse Fourier transform?
Let $f(x)$ be defined as
$$f(x)=\begin{cases}\cos(x)&|x|\le \pi/2\\\\0&,|x|\ge\pi/2\end{cases}$$
We can write $f(x)=\cos(x)\text{rect}(x/\pi)$ in terms of the rectangular function
$$\text{rect}(x)=\begin{cases} 1&, |x|<1/2\\\\0&,|x|>1/2 \end{cases}$$
Then, we have in distribution
$$f'(x)=-\sin(x)\text{rect}(x/\pi) $$
and
$$f''(x)=-\cos(x)\text{rect}(x/\pi)+\delta(x-\pi/2)+\delta(x+\pi/2)$$
So, the Fourier Transform of $f''(x)$ is
$$\begin{align} \mathscr{F}\{f''\}(\omega)&=\mathscr{F}\{-f\}+e^{-i\omega \pi/2}+e^{i\omega \pi/2}\\\\ &=-\frac{2\cos(\omega \pi/2)}{1-\omega^2}+2\cos(\omega \pi/2)\\\\ &=-\frac{2\omega^2 \cos(\omega \pi/2)}{1-\omega^2}\\\\ &=-\omega^2 \mathscr{F}\{f\}(\omega) \end{align}$$
as expected!