CMake: Use pthread library when requested and available.