# Marking headers as SYSTEM does not suppress warnings on Windows.

**URL:** https://discourse.cmake.org/t/marking-headers-as-system-does-not-suppress-warnings-on-windows/6415
**Category:** Code
**Tags:** os:windows
**Created:** [September 5, 2022, 8:41pm UTC](https://discourse.cmake.org/t/marking-headers-as-system-does-not-suppress-warnings-on-windows/6415 "2022-09-05T20:41:54Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![rokoDev](https://discourse.cmake.org/user_avatar/discourse.cmake.org/rokodev/32/2742_2.png) [@rokoDev](https://discourse.cmake.org/u/rokoDev)
#### Post date: [September 5, 2022, 8:41pm UTC](https://discourse.cmake.org/t/marking-headers-as-system-does-not-suppress-warnings-on-windows/6415/1 "2022-09-05T20:41:54Z")

</div>

Hi 🙂 I need to compile unit tests for simple project with some warnings turned on. But I want to suppress this warnings from being arisen in an external `INTERFACE` library(actually this is my fork from **Boost.Leaf** with added `SYSTEM` option) and to achieve this I have added `SYSTEM` option in `target_include_directories`:

```auto
# Generated by `boostdep --cmake leaf`
# Copyright 2020 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# https://www.boost.org/LICENSE_1_0.txt

cmake_minimum_required(VERSION 3.5...3.16)

project(boost_leaf VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)

add_library(boost_leaf INTERFACE)
add_library(Boost::leaf ALIAS boost_leaf)

target_include_directories(boost_leaf SYSTEM INTERFACE include)

if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt")

  add_subdirectory(test)

endif()

```

This works fine on **Linux** and **MacOS** but unfortunately not for **Windows** because warnings keeps being arisen in the external library([here](https://ci.appveyor.com/project/rokoDev/buffer/branch/develop/job/sbr72u4t39cc1a1s) you can see errors arisen in **boost/leaf/handle\_errors.hpp** which in theory must be suppressed)

If this can be useful the project that I try to compile can be found on [github](https://github.com/rokoDev/buffer/tree/develop)

Any idea what I’m doing wrong and how to suppress those warnings?

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [September 5, 2022, 9:28pm UTC](https://discourse.cmake.org/t/marking-headers-as-system-does-not-suppress-warnings-on-windows/6415/2 "2022-09-05T21:28:02Z")

</div>

Ignoring warnings from system headers is only supported with MSVC with the Ninja generators as of CMake 3.22 and the Visual Studio generators as of CMake 3.24. Of course, an MSVC of at least (compiler) version `19.29.30036.3` is required (the 14.29 toolchain in the Visual Studio installer).
