visual-studioclang-clvisual-studio-2019

How to disable clang-cl specific warnings in VS project


I use a 3rd party project, that produces huge amount of warnings. I disable all of them in VS project properties. Sometimes, I switch to LLVM clang-cl toolset to check for warnings from clang. The 3rd party project produces so many warnings with clang-cl that VS is chocking with the amount of output. I know how to disable them, I do so through command line args, for example: Wno-int-conversion -Wno-shift-op-parentheses etc. The problem, however, when I switch back to VS toolset, all of these command line params to disable warnings from clang-cl become errors (unknown cmd line args) with MS compiler.

Is there a way to have both clang and VS settings in the same VS project? Maybe, somehow conditional on ClangCL toolset these could be added only for clang-cl builds?


Solution

  • The first thing I tried worked right away, in case if anybody needs to solve the same problem:

      <AdditionalOptions Condition="'$(PlatformToolset)'!='ClangCL'">/w24003 /w24005 ... %(AdditionalOptions)</AdditionalOptions>
      <AdditionalOptions Condition="'$(PlatformToolset)'=='ClangCL'">-Wno-unknown-pragmas -Wno-unused-variable ...  %(AdditionalOptions)</AdditionalOptions>
    

    This way, with using LLVM clang-cl toolset with VS only clang cpecific command line params applies, and when using ms compiler, only ms compiler specific options are applied.