Adds logic to add Thread sanitizer as an option.

With checks if the compiler supports one type of flag and if both tsan and asan are enabled as this is not supported.