# Install findPackage script

**URL:** https://discourse.cmake.org/t/install-findpackage-script/5307
**Category:** Code
**Created:** [March 28, 2022, 8:27am UTC](https://discourse.cmake.org/t/install-findpackage-script/5307 "2022-03-28T08:27:50Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Leon0402](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/l/ccd318/32.png) [@Leon0402](https://discourse.cmake.org/u/Leon0402)
#### Post date: [March 28, 2022, 8:27am UTC](https://discourse.cmake.org/t/install-findpackage-script/5307/1 "2022-03-28T08:27:50Z")

</div>

Hi,

for a project I have some deependencies like MySQL. I therefore also have a FindMySQL.cmake script. In my Config script, when my project is installed, I have `find_dependency(MySQL)`, because well mysql is a dependency.  
But the `FindMySQL.cmake` is not installed and therefore users will get an error message that there is no such script and therefore mysql cannot be found.

So there are two solutions:

1. Users provide the scripts themself
2. I ship them

Shipping them sounds more comfortable for the user. Is it best practice? What would be the way to do this? My initial thought would be:

1. Install it in the same directory as my Config Script
2. In my config script set the cmake module path to the current directory

Is this correct?

---

<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: [March 29, 2022, 1:28pm UTC](https://discourse.cmake.org/t/install-findpackage-script/5307/2 "2022-03-29T13:28:03Z")

</div>

Shipping your own `Find` modules is fine.

> [@Leon0402](#):
>
> Install it in the same directory as my Config Script

I’d recommend a subdirectory just to keep it more obvious what is what.

> [@Leon0402](#):
>
> In my config script set the cmake module path to the current directory

Yep. I’d recommend removing it after you’ve completed it though. See the discussion here:

> [@Can't export top level lib with dependency on subdir lib](https://discourse.cmake.org/t/cant-export-top-level-lib-with-dependency-on-subdir-lib/1084/21):
>
> They should just need to do find\_package(yourprogram). yourprogram-config.cmake does find\_package() for your dependencies to bring in their imported targets. I usually add them to cmake in the source tree and beside yourpackage-config.cmake in the build/install tree. Just scope it so your Find modules don’t interfere with the caller’s. set(CMAKE\_MODULE\_PATH\_save "${CMAKE\_MODULE\_PATH}") list(INSERT CMAKE\_MODULE\_PATH 0 "${CMAKE\_CURRENT\_LIST\_DIR}") # Any find\_packages you need. set(CMAKE\_MODULE…

---

<div class="post-metadata">

### Author: ![Leon0402](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/l/ccd318/32.png) [@Leon0402](https://discourse.cmake.org/u/Leon0402)
#### Post date: [March 30, 2022, 7:56pm UTC](https://discourse.cmake.org/t/install-findpackage-script/5307/3 "2022-03-30T19:56:28Z")

</div>

Thanks, that worked out!
