# How do cmake policy warnings work?

**URL:** https://discourse.cmake.org/t/how-do-cmake-policy-warnings-work/10555
**Category:** Usage
**Created:** [April 2, 2024, 5:08pm UTC](https://discourse.cmake.org/t/how-do-cmake-policy-warnings-work/10555 "2024-04-02T17:08:39Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![JRR](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/j/ecccb3/32.png) [@JRR](https://discourse.cmake.org/u/JRR)
#### Post date: [April 2, 2024, 5:08pm UTC](https://discourse.cmake.org/t/how-do-cmake-policy-warnings-work/10555/1 "2024-04-02T17:08:39Z")

</div>

I’m looking for clarification on how cmake policy warnings work. In particular the policy warnings for [`CMP0112`](https://cmake.org/cmake/help/latest/policy/CMP0112.html#policy:CMP0112).

We have code that triggers the warning for [`CMP0112`](https://cmake.org/cmake/help/latest/policy/CMP0112.html#policy:CMP0112). We validated our usage is fine and use

```auto
cmake_policy(SET CMP0112 NEW)

```

However, whenever we use the `--trace-expand` flag to investigate issues we’re having. The output is inundated with warnings for [`CMP0112`](https://cmake.org/cmake/help/latest/policy/CMP0112.html#policy:CMP0112) saying it’s not set, blah, blah, blah.

```auto
CMake Warning (dev):
  Policy CMP0112 is not set: Target file component generator expressions do
  not add target dependencies. Run "cmake --help-policy CMP0112" for policy
  details. Use the cmake_policy command to set the policy and suppress this
  warning.

  Dependency being added to target:

    "<magical-target-here>"

This warning is for project developers. Use -Wno-dev to suppress it.

```

I saw a reference to [`CMAKE_POLICY_WARNING_CMP0112`](https://cmake.org/cmake/help/latest/variable/CMAKE_POLICY_WARNING_CMPNNNN.html#variable:CMAKE_POLICY_WARNING_CMP%3CNNNN%3E) in the description of [`CMP0112`](https://cmake.org/cmake/help/latest/policy/CMP0112.html#policy:CMP0112) which seems to imply that this warning is turned on no matter what if we are running in trace mode or debug mode.

Is this understanding correct? And if so, how do I stop it.

I’ve used code to deal with this. I never want to see this warning again, it’s not a problem, how do I get this to not show up even under debug or trace mode? I only want to see warnings for things that haven’t been taken care of.

I don’t want to use `-Wno-dev` because I don’t want to suppress all warnings, just the ones we’ve already taken care of.

These warnings are red herrings.

---

<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: [April 11, 2024, 4:25pm UTC](https://discourse.cmake.org/t/how-do-cmake-policy-warnings-work/10555/2 "2024-04-11T16:25:54Z")

</div>

Can you please provide a test case that can be used to investigate the problem more deeply? There may just be a bug in the policy behavior detection (or the behavior is happening outside of the policy scope you’re setting…). Hard to say with the details provided at the moment.

---

<div class="post-metadata">

### Author: ![JRR](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/j/ecccb3/32.png) [@JRR](https://discourse.cmake.org/u/JRR)
#### Post date: [May 9, 2024, 10:32pm UTC](https://discourse.cmake.org/t/how-do-cmake-policy-warnings-work/10555/3 "2024-05-09T22:32:42Z")

</div>

Nuts!!!

I got distracted and didn’t get back to this until now, and 28 days later… I no longer remember the context myself, nor can I find the context. I’m guessing it was an experimental package I was working with/testing that I’ve since forgotten.

Apologies, for not following up in a timely manner or with necessary information.
