Add checking for and linking with libgthread