Fix compilation issues. Among other things, detect the version of clang in cmake for the thread safety warnings.