Results 2 issues of sanjosh

Added pthread dependency Set compiler flags using set() instead of list(APPEND, ) to prevent the problem discussed here http://stackoverflow.com/questions/16433391/cmake-list-append-for-compiler-flags-yields-bogus-results