Robustify CMake files for pthreads

It has been reported that on some platforms pthread lib was missing during
linking.

Signed-off-by: Olivier Langlois <olivier@trillion01.com>