# Environment variable \<PackageName\>\_ROOT ignored with a cmake minimum required 3.22

**URL:** https://discourse.cmake.org/t/environment-variable-packagename-root-ignored-with-a-cmake-minimum-required-3-22/13364
**Category:** Code
**Tags:** os:linux, gen:makefiles
**Created:** [January 9, 2025, 9:23pm UTC](https://discourse.cmake.org/t/environment-variable-packagename-root-ignored-with-a-cmake-minimum-required-3-22/13364 "2025-01-09T21:23:55Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![tpadioleau](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/t/fbc32d/32.png) [@tpadioleau](https://discourse.cmake.org/u/tpadioleau)
#### Post date: [January 9, 2025, 9:23pm UTC](https://discourse.cmake.org/t/environment-variable-packagename-root-ignored-with-a-cmake-minimum-required-3-22/13364/1 "2025-01-09T21:23:55Z")

</div>

Hello, I recently faced a curious situation.

My project has the following structure: my CMakeLists.txt starts with a cmake\_minimum\_required(VERSION 3.22) then calls find\_package(Foo REQUIRED). The file FooConfig.cmake calls find\_dependency(Bar) then find\_dependency(Baz). My environment contains the variables Foo\_ROOT, Bar\_ROOT and Baz\_ROOT.

The configuration stopped because cmake could not find Baz. During the configuration it displayed the warning “Policy CMP0074 is not set: find\_package uses \_ROOT variables.”.

I found it surprising as the minimum required that I asked should have defined the policy CMP0074 to NEW.

I noticed that the file BarConfig.cmake was calling cmake\_minimum\_required(VERSION 3.8) then include(CMakeFindDependencyMacro). My understanding is that the macro find\_dependency was redefined capturing a policy CMP0074 unset due to the new minimum required 3.8. Back in the file FooConfig.cmake, the find\_dependency(Baz) command called find\_package in a scope where the policy CMP0074 was then unset thus ignoring the Baz\_ROOT variable.

Can you confirm that it makes sense ?

---

<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: [December 28, 2025, 7:04am UTC](https://discourse.cmake.org/t/environment-variable-packagename-root-ignored-with-a-cmake-minimum-required-3-22/13364/2 "2025-12-28T07:04:36Z")

</div>

Leaving this here since it has been referenced by another discussion.

When CMake generates files with `install(EXPORT)`, it uses this pattern:

```cmake
cmake_policy(PUSH)
cmake_policy(VERSION 2.8.3...4.0)

# ...things from the export set appear here

cmake_policy(POP)

```

The minimum and maximum values in the `cmake_policy(VERSION)` command are updated from time-to-time in CMake releases, especially the maximum of that version range. Projects would do well to follow a similar pattern in their own `packageName-config.cmake` files. This does, however, mean packages need to not fall too far behind the latest CMake release, otherwise they risk generating deprecation or policy warnings whenever their package is used by consumers.

For the scenario described in this thread, it sounds like the package being consumed may have done this, or at least has called `cmake_policy(...)` or `cmake_minimum_version()`, but it apears to have specified an older CMake version (it would have to be 3.11 or older to generate a warning for CMP0074). Most likely, it just specifies a single version rather than a version range (version ranges only became a thing with CMake 3.12).

Your options here would be limited. Updating to a newer version of the offending package would be the simplest and recommended solution if newer package versions addressed this problem. If that isn’t possible or newer packages still have the issue, you could potentially try using the [`CMAKE_POLICY_DEFAULT_CMP0074`](https://cmake.org/cmake/help/latest/variable/CMAKE_POLICY_DEFAULT_CMPNNNN.html#variable:CMAKE_POLICY_DEFAULT_CMP%3CNNNN%3E) variable to override the dependency’s policy settings, but that’s not ideal.
