# Disable CMake Warnings for FetchContent

**URL:** https://discourse.cmake.org/t/disable-cmake-warnings-for-fetchcontent/11263
**Category:** Usage
**Created:** [July 16, 2024, 12:29pm UTC](https://discourse.cmake.org/t/disable-cmake-warnings-for-fetchcontent/11263 "2024-07-16T12:29:28Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![MarcelKoch](https://discourse.cmake.org/user_avatar/discourse.cmake.org/marcelkoch/32/4769_2.png) [@MarcelKoch](https://discourse.cmake.org/u/MarcelKoch)
#### Post date: [July 16, 2024, 12:29pm UTC](https://discourse.cmake.org/t/disable-cmake-warnings-for-fetchcontent/11263/1 "2024-07-16T12:29:28Z")

</div>

Hello,

Is it possible to disable CMake warning (`-Wdev`) only for a package that is added via `FetchContent`? The documentation for the `-Wdev` option doesn’t offer any suggestion for this, and neither does the documentation of `FetchContent`.

---

<div class="post-metadata">

### Author: ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)
#### Post date: [July 16, 2024, 10:35pm UTC](https://discourse.cmake.org/t/disable-cmake-warnings-for-fetchcontent/11263/2 "2024-07-16T22:35:03Z")

</div>

Depends on the actual warning you want to hide. There are variables like `CMAKE_WARN_DEPRECATED` and `CMAKE_POLICY_WARNING_CMP<NNNN>` which can be used to hide those specific types of warnings, and you could use something like `CMAKE_PROJECT_<projectName>_INCLUDE` to set them just for specific projects (but note that the variables would then apply to any dependencies that project pulled in too).

---

<div class="post-metadata">

### Author: ![MarcelKoch](https://discourse.cmake.org/user_avatar/discourse.cmake.org/marcelkoch/32/4769_2.png) [@MarcelKoch](https://discourse.cmake.org/u/MarcelKoch)
#### Post date: [July 17, 2024, 8:56am UTC](https://discourse.cmake.org/t/disable-cmake-warnings-for-fetchcontent/11263/3 "2024-07-17T08:56:26Z")

</div>

The warnings are exclusively for uninitialized variables. It doesn’t seem like there is a CMake variable to suppress these warnings, so from what I can gather it’s impossible to suppress these warnings for a dependency.

---

<div class="post-metadata">

### Author: ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)
#### Post date: [July 17, 2024, 12:13pm UTC](https://discourse.cmake.org/t/disable-cmake-warnings-for-fetchcontent/11263/4 "2024-07-17T12:13:42Z")

</div>

Ah, yes enabling or disabling uninitialised warnings can only be done at a whole-of-build level. I find that warning to be fairly questionable personally, given the prevalence of using variables uninitialised. Unlike some other languages, that is still well-defined behavior in CMake.

---

<div class="post-metadata">

### Author: ![MarcelKoch](https://discourse.cmake.org/user_avatar/discourse.cmake.org/marcelkoch/32/4769_2.png) [@MarcelKoch](https://discourse.cmake.org/u/MarcelKoch)
#### Post date: [July 17, 2024, 1:50pm UTC](https://discourse.cmake.org/t/disable-cmake-warnings-for-fetchcontent/11263/5 "2024-07-17T13:50:22Z")

</div>

It might be well-defined for CMake, but in our project we still want to count this as a warning, and most likely want to fix that. But for now, we will just live with that, and probably try to provide some upstream patches for the warnings in other projects.
