# find\_package() not working from a subdirectory

**URL:** https://discourse.cmake.org/t/find-package-not-working-from-a-subdirectory/4632
**Category:** Usage
**Created:** [December 9, 2021, 8:05pm UTC](https://discourse.cmake.org/t/find-package-not-working-from-a-subdirectory/4632 "2021-12-09T20:05:15Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![mscofield0](https://discourse.cmake.org/user_avatar/discourse.cmake.org/mscofield0/32/1413_2.png) [@mscofield0](https://discourse.cmake.org/u/mscofield0)
#### Post date: [December 9, 2021, 8:05pm UTC](https://discourse.cmake.org/t/find-package-not-working-from-a-subdirectory/4632/1 "2021-12-09T20:05:15Z")

</div>

Why is that the case? Why does it need to be in the root CMakeLists.txt?

---

<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 10, 2021, 12:05am UTC](https://discourse.cmake.org/t/find-package-not-working-from-a-subdirectory/4632/2 "2021-12-10T00:05:08Z")

</div>

`find_package()` creates variables and targets in the scope from which it is called. The imported targets it creates are non-global by default, so those won’t be visible to sibling scopes. Similarly, variables created by the call are also not visible to sibling scopes because subdirectories create a new variable scope. So if you need to reference something defined by `find_package()`, then you need to ensure that `find_package()` call is in the same directory or a parent directory.
