The Integral, as stated diverges at $x=1$ and $x=2$, but the Cauchy Principal Value can be computed.
$$
\begin{align}
\mathrm{PV}\int_{-\infty}^\infty\frac{x\cos(x)\,\mathrm{d}x}{(x-1)(x-2)}
&=\frac12\int_{\gamma^+}\frac{ze^{iz}\,\mathrm{d}z}{(z-1)(z-2)}
+\frac12\int_{\gamma^-}\frac{ze^{-iz}\,\mathrm{d}z}{(z-1)(z-2)}\\
&\color{#C00000}{+\frac{\pi i}{2}\operatorname*{Res}_{z=1}\left(\frac{ze^{iz}}{(z-1)(z-2)}\right)
+\frac{\pi i}{2}\operatorname*{Res}_{z=2}\left(\frac{ze^{iz}}{(z-1)(z-2)}\right)}\\
&\color{#00A000}{-\frac{\pi i}{2}\operatorname*{Res}_{z=1}\left(\frac{ze^{-iz}}{(z-1)(z-2)}\right)
-\frac{\pi i}{2}\operatorname*{Res}_{z=2}\left(\frac{ze^{-iz}}{(z-1)(z-2)}\right)}\\
&=\frac{\pi i}{2}\frac{e^i}{-1}+\frac{\pi i}{2}\frac{2e^{2i}}{1}
-\frac{\pi i}{2}\frac{e^{-i}}{-1}-\frac{\pi i}{2}\frac{2e^{-2i}}{1}\\[9pt]
&=\pi\sin(1)-2\pi\sin(2)
\end{align}
$$
where $\gamma^+$ consists of the straight line contours and upper semi-circles; that is,
$$
[-R,1-r]\cup1+re^{i[\pi,0]}\cup[1+r,2-r]\cup2+re^{i[\pi,0]}\cup[2+r,R]\cup Re^{i[0,\pi]}
$$
and $\gamma^-$ consists of the straight line contours and lower semi-circles; that is,
$$
[-R,1-r]\cup1+re^{-i[\pi,0]}\cup[1+r,2-r]\cup2+re^{-i[\pi,0]}\cup[2+r,R]\cup Re^{-i[0,\pi]}
$$
The integrals around the two large semi-circles, in blue, vanish. Since there are no singularities contained in either contour, their integrals are $0$. For the principal value, which is just the integral over the straight line contours, we must subtract the contributions from the red and green semi-circles; this is done using the residues at $z=1$ and $z=2$.
This can also be computed using only $\gamma^+$ if we take the real part.
$$
\begin{align}
\mathrm{PV}\int_{-\infty}^\infty\frac{x\cos(x)\,\mathrm{d}x}{(x-1)(x-2)}
&=\mathrm{Re}\left(\int_{\gamma^+}\frac{ze^{iz}\,\mathrm{d}z}{(z-1)(z-2)}
\right)\\
&+\mathrm{Re}\left[\pi i\operatorname*{Res}_{z=1}\left(\frac{ze^{iz}}{(z-1)(z-2)}\right)
+\pi i\operatorname*{Res}_{z=2}\left(\frac{ze^{iz}}{(z-1)(z-2)}\right)\right]\\
&=\mathrm{Re}\left(\pi i\frac{e^i}{-1}+\pi i\frac{2e^{2i}}{1}\right)\\[6pt]
&=\pi\sin(1)-2\pi\sin(2)
\end{align}
$$