title: C++ compiler flag to ignore warnings for external libraries but without including directory
body: <p>There are two ways, as far as I can tell, to ignore warnings for external libraries.</p>
  
  <p>First way is to use <code>#pragma</code>:</p>
  
  <pre><code>#pragma gcc diagnostic ignored "-Wunused-parameter"
  </code></pre>
  
  <p>Second way is to add <code>-isystem/path/to/system/lib</code> to the compiler flags. This labels that particular include path as an external include path, and so the compiler will not emit warnings stemming from those includes.</p>
  
  <p>I have a large project with many compilation targets, some of which use particular third party libraries which cause problems for my compiler. For reasons I cannot use the <code>#pragma</code> option.</p>
  
  <p>But if I use the <code>-isystem</code> as a blanket compiler flag for all build targets, then I will unfortunately include <code>/path/to/system/lib</code> for every other build target, even those which do not use that system library. This means other targets will search through those external libraries, which is not desirable.</p>
  
  <p>Is there a compiler option, similar to <code>-isystem</code> which can be added in a blanket way, which <em>does not add to the search path</em>, but only excludes warnings if the path happens to already be included in the search path?</p>