Let's look at
$$I(a) = \int_\mathbb{R} \frac{e^{iax}}{1+x^2}\,dx$$
for $a\in \mathbb{R}$. If $a\geqslant 0$, then the exponential $e^{iaz}$ is bounded in the upper half-plane, so one can evaluate $I(a)$ by using a semicircular contour consisting of the interval $[-R,R]$ on the real axis and the semicircle $Re^{it},\, t\in [0,\pi]$ in the upper half-plane. The standard estimate shows that the integral over the semicircle tends to $0$ for $R\to \infty$, so the residue theorem yields
$$I(a) = 2\pi i\sum_{\operatorname{Im}\zeta > 0} \operatorname{Res}\left(\frac{e^{iaz}}{1+z^2}; \zeta\right) = 2\pi i \operatorname{Res}\left(\frac{e^{iaz}}{1+z^2}; i\right).$$
For $a < 0$, the exponential $e^{iaz}$ is not bounded in the upper half-plane, it grows exponentially for $\operatorname{Im} z \to +\infty$, so we cannot use the same contour in that case. But $e^{iaz}$ is bounded in the lower half-plane for $a < 0$, so we can use a semicircle in the lower half-plane, $Re^{-it},\, t\in [0,\pi]$ to close the contour. Again, the standard estimate shows that the integral over the semicircle tends to $0$ as $R\to\infty$, and - note the orientation of the contour - the residue theorem yields
$$I(a) = -2\pi i\sum_{\operatorname{Im}\zeta < 0} \operatorname{Res}\left(\frac{e^{iaz}}{1+z^2}; \zeta\right) = -2\pi i \operatorname{Res}\left(\frac{e^{iaz}}{1+z^2}; -i\right)$$
then.
Of course in this particular case, parity shows that $I(a) = I(-a) = I(\lvert a\rvert)$, so we can get by with only the contour in the (closed) upper half-plane here, but generally, no such short-cuts are available.
Then, to evaluate the integral
$$\int_\mathbb{R} \frac{\cos x}{1+x^2} e^{-itx}\,dx$$
one can use Eulers formula for the cosine to get it into the form $\frac{1}{2}(I(a_1) - I(a_2))$.