CMake: fix FreeBSD examples compilation by adding threading library