If the function $f$ is periodic, then it is clear we can write $f$ in terms of its Fourier series:
$$f(t) = \frac{a_0}{2} + \sum_{k=1}^{\infty} \left (a_k \cos{k t} + b_k \sin{k t} \right ) $$
Now, the RHS is simply proportional to $\cos{x}$. By the orthogonality of the sine and cosine, all we need worry about then are the $k=1$ terms.
Plugging away, we find that the integral is equal to
$$\int_{-\pi}^{\pi} dt \left (a_1 \cos{t} + b_1 \sin{t} \right ) \left (a_1 \cos{(x-t)} + b_1 \sin{(x-t)} \right )$$
which the reader can verify is, again using orthogonality to make life easy,
$$(a_1^2-b_1^2) \pi \cos{x} + 2 a_1 b_1 \pi \sin{x} $$
This expression must be identically equal to $-\cos{x}$. This means that $a_1 b_1=0$, so either $a_1$ or $b_1$ is zero. But if $b_1$ were zero, the expression on the LHS must be positive, which is false. Thus, $a_1=0$ and hence,
$$f(t) = \pm \frac1{\sqrt{\pi}} \sin{t}$$