Add CheckCXXLibraryExists.cmake module and use it in FindTreadsCXX.cmake.