Fix thread linking for gtest under ubuntu.

This issue is a regression introduced in the last commit.