Disable CMake Warnings for FetchContent

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.

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).

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.

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.

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.