properly detect libgthread on BSD systems