Update CMakeLists.txt to find pthreads.
Update CMakeLists.txt to find pthreads.

CMake now looks for the existence of pthreads and exits on error in case it's
not found. Moreover, it passes the appropriate flags (-pthread/-lpthread) to the
compiler and to the linker, avoiding errors on some platforms.

alexandrelucchesi/qlibc,alexandrelucchesi/qlibc,alexandrelucchesi/qlibc