# find\_package NAMES \<PackageName\>\_FOUND

**URL:** https://discourse.cmake.org/t/find-package-names-packagename-found/10617
**Category:** Usage
**Tags:** os:linux
**Created:** [April 9, 2024, 9:38am UTC](https://discourse.cmake.org/t/find-package-names-packagename-found/10617 "2024-04-09T09:38:29Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![loesch](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/l/a88e57/32.png) [@loesch](https://discourse.cmake.org/u/loesch)
#### Post date: [April 9, 2024, 9:38am UTC](https://discourse.cmake.org/t/find-package-names-packagename-found/10617/1 "2024-04-09T09:38:29Z")

</div>

I am asking to help me for some _ **find\_package** _ behavior for two packages:

- PackageName1: a system supplied package
- PackageName2: self build newer version of PackageName1

If I apply the _ **find\_package** _ command with:  
**find\_package(PackageName1 CONFIG)**  
I get _ **PackageName1\_FOUND** _ with value _ **TRUE** _ as expected.

If I do a similar find to prefer the self compiled package using:  
**find\_package(PackageName1 NAMES PackageName2 CONFIG)**  
I get:  
_PackageName1\_FOUND = FALSE_  
_PackageName2\_FOUND =_

The documentation states _… If the NAMES option is given, the names following it are used instead of PackageName. …_ . Therefore I expected to get at least:  
_PackageName2\_FOUND = TRUE_  
or  
_PackageName1\_FOUND = TRUE_  
_PackageName2\_FOUND = TRUE_

Am I doing something wrong or interpret the subject false?

I appreciate any help to clarify the subject. Thanks in advance.  
Siegfried

---

<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, 5:36pm UTC](https://discourse.cmake.org/t/find-package-names-packagename-found/10617/2 "2024-04-11T17:36:36Z")

</div>

The found package might not use `CMAKE_FIND_PACKAGE_NAME` when setting variables and instead only sets `PackageName1_FOUND` statically.

---

<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: [April 11, 2024, 11:04pm UTC](https://discourse.cmake.org/t/find-package-names-packagename-found/10617/3 "2024-04-11T23:04:50Z")

</div>

The `XXX_FOUND` variable should always use the first argument to `find_package()` as the `XXX` prefix. The `NAMES` are irrelevant as far as the output variable is concerned, those names are only to guide the search. For your specific example, you are only calling `find_package()` with `PackageName1` as the first argument, so you should only be looking at `PackageName1_FOUND`. You should not take any notice of whether `PackageName2_FOUND` is set or not. If it is, that’s an implementation detail that you shouldn’t be relying on (in so far as you’ve asked to get the result reported back through `PackageName1_FOUND` since that’s your first argument to `find_package()`).

---

<div class="post-metadata">

### Author: ![loesch](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/l/a88e57/32.png) [@loesch](https://discourse.cmake.org/u/loesch)
#### Post date: [April 23, 2024, 5:34pm UTC](https://discourse.cmake.org/t/find-package-names-packagename-found/10617/4 "2024-04-23T17:34:35Z")

</div>

Wasn’t aware of CMAKE\_FIND\_PACKAGE\_NAME at all and will use that in future pkg config files. Thanks!

---

<div class="post-metadata">

### Author: ![loesch](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/l/a88e57/32.png) [@loesch](https://discourse.cmake.org/u/loesch)
#### Post date: [April 23, 2024, 5:36pm UTC](https://discourse.cmake.org/t/find-package-names-packagename-found/10617/5 "2024-04-23T17:36:16Z")

</div>

Having your answer in mind the behavior is clear for me now! Thanks!
