# How to use find\_package(X CONFIG) results?

**URL:** https://discourse.cmake.org/t/how-to-use-find-package-x-config-results/5819
**Category:** Usage
**Created:** [June 7, 2022, 7:33pm UTC](https://discourse.cmake.org/t/how-to-use-find-package-x-config-results/5819 "2022-06-07T19:33:11Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![tomoreilly](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/t/439d5e/32.png) [@tomoreilly](https://discourse.cmake.org/u/tomoreilly)
#### Post date: [June 7, 2022, 7:33pm UTC](https://discourse.cmake.org/t/how-to-use-find-package-x-config-results/5819/1 "2022-06-07T19:33:11Z")

</div>

How to know how a particular package X responds to find\_package(X CONFIG)?  
If the package is found then I assume variable X\_FOUND is always set. But there doesn’t seem be a “standard” way of setting other result variables. E.g I’ve seen some packages set X\_LIBRARIES to an actual library file (e.g. /usr/local/lib/libX.so), other packages to an IMPORTED target (e.g. X::Y), and some packages don’t set X\_LIBRARIES at all, somehow the IMPORTED target is implied. Some packages set X\_VERSION, others do not. Is there no way for my CMakeLists.txt to “know” how to use the find\_package(X CONFIG) result, short of me searching for details on the X package website or on a discussion forum?

---

<div class="post-metadata">

### Author: ![klirichek](https://discourse.cmake.org/user_avatar/discourse.cmake.org/klirichek/32/1657_2.png) [@klirichek](https://discourse.cmake.org/u/klirichek)
#### Post date: [June 8, 2022, 6:47am UTC](https://discourse.cmake.org/t/how-to-use-find-package-x-config-results/5819/2 "2022-06-08T06:47:55Z")

</div>

I think, after find\_package you’re going to use it someway. Usually by linking with X::Y.  
So, if (TARGET X::Y) will be a good enough sigh, at list, in modern-style cmake.

X\_LIBRARIES might not be the case if the package is headers-only  
X\_FOUND is conveniently set by FindPackageHandleStandardArgs, that is helpful, but nobody strictly demand to use it.

Anyway, if regard FindX.cmake as the special script following the rules, it usually uses FindPackageHandleStandardArgs, and now it is also usually provides imported target. And also it includes kind of comprehensive enough instruction at the top of the module. But if it is just a file which named right way, but with legacy inside - it seems, there is no generally common way to deal with it

---

<div class="post-metadata">

### Author: ![marc.chevrier](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/m/ecb155/32.png) [@marc.chevrier](https://discourse.cmake.org/u/marc.chevrier)
#### Post date: [June 8, 2022, 9:34am UTC](https://discourse.cmake.org/t/how-to-use-find-package-x-config-results/5819/3 "2022-06-08T09:34:08Z")

</div>

@tomoreilly In the contrary, there is a [standard](https://cmake.org/cmake/help/latest/manual/cmake-developer.7.html#standard-variable-names) for variables defined by a module.

But, after, it is the responsibility of the module’s developer to follow (or not) this standard.

---

<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: [June 8, 2022, 1:52pm UTC](https://discourse.cmake.org/t/how-to-use-find-package-x-config-results/5819/4 "2022-06-08T13:52:11Z")

</div>

> [@tomoreilly](#):
>
> Is there no way for my CMakeLists.txt to “know” how to use the find\_package(X CONFIG) result, short of me searching for details on the X package website or on a discussion forum?

Nope. The docs at the top of the file should help (if present). Otherwise, see the project docs (they should mention this kind of stuff).
