# Ideal way to force find\_package to use a given folder

**URL:** https://discourse.cmake.org/t/ideal-way-to-force-find-package-to-use-a-given-folder/10046
**Category:** Usage
**Created:** [February 9, 2024, 4:59pm UTC](https://discourse.cmake.org/t/ideal-way-to-force-find-package-to-use-a-given-folder/10046 "2024-02-09T16:59:58Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![fzakaria](https://discourse.cmake.org/user_avatar/discourse.cmake.org/fzakaria/32/4294_2.png) [@fzakaria](https://discourse.cmake.org/u/fzakaria)
#### Post date: [February 9, 2024, 4:59pm UTC](https://discourse.cmake.org/t/ideal-way-to-force-find-package-to-use-a-given-folder/10046/1 "2024-02-09T16:59:58Z")

</div>

We are using `find_package` in CONFIG mode and our developer instructions require setting `PACKAGE_DIR` as the location when running the cmake.  
The directory is a git-submodule at a very specific commit we need  
(FWIW package is LLVM)

I found that some users who may have the package installed via something such as homebrew on MacOS and cmake is picking up that installation instead.

I am surprised us setting PACKAGE\_DIR on the command line is not overriding the search.  
Is there something else we should be doing?

---

<div class="post-metadata">

### Author: ![ClausKlein](https://discourse.cmake.org/user_avatar/discourse.cmake.org/clausklein/32/352_2.png) [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)
#### Post date: [February 9, 2024, 11:08pm UTC](https://discourse.cmake.org/t/ideal-way-to-force-find-package-to-use-a-given-folder/10046/2 "2024-02-09T23:08:01Z")

</div>

Dit you try to set [CMAKE\_PREFIX\_PATH](https://cmake.org/cmake/help/v3.28/envvar/CMAKE_PREFIX_PATH.html#cmake-prefix-path)?

---

<div class="post-metadata">

### Author: ![fzakaria](https://discourse.cmake.org/user_avatar/discourse.cmake.org/fzakaria/32/4294_2.png) [@fzakaria](https://discourse.cmake.org/u/fzakaria)
#### Post date: [February 13, 2024, 5:47pm UTC](https://discourse.cmake.org/t/ideal-way-to-force-find-package-to-use-a-given-folder/10046/3 "2024-02-13T17:47:56Z")

</div>

Turned out the person had some environment variables that were causing problems ☹

Thank you for responding though.

---

<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: [February 17, 2024, 6:04am UTC](https://discourse.cmake.org/t/ideal-way-to-force-find-package-to-use-a-given-folder/10046/4 "2024-02-17T06:04:11Z")

</div>

> [@fzakaria](#):
>
> Turned out the person had some environment variables that were causing problems ☹

If you didn’t know, passing the `--debug-find` flag when configuring can help track down these kinds of things.
