Correct the problem with -pthread flag when building with CMake. Should fix issue ROOT-6390