Add pthread to semaphore CMake check

Some systems have sem_wait in librt, some in libpthread.
This add pthread to the CMake check for semaphore support.

Released under the MIT license.