cmake: Support pthread in the main library Improve pthread support for the main library when building via CMake. Explicitly request pthread when multiple threading options are available since the code is using pthread directly. Set HAVE_LIBPTHREAD to trigger the code, link the library and list it in pkg-config file.