# Ignoring CMake's delivered Find\<Package\>.cmake to favor external Library's Config.cmake

**URL:** https://discourse.cmake.org/t/ignoring-cmakes-delivered-find-package-cmake-to-favor-external-librarys-config-cmake/3236
**Category:** Usage
**Tags:** os:linux
**Created:** [April 29, 2021, 12:50pm UTC](https://discourse.cmake.org/t/ignoring-cmakes-delivered-find-package-cmake-to-favor-external-librarys-config-cmake/3236 "2021-04-29T12:50:36Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![brentd](https://discourse.cmake.org/user_avatar/discourse.cmake.org/brentd/32/3596_2.png) [@brentd](https://discourse.cmake.org/u/brentd)
#### Post date: [April 29, 2021, 12:50pm UTC](https://discourse.cmake.org/t/ignoring-cmakes-delivered-find-package-cmake-to-favor-external-librarys-config-cmake/3236/1 "2021-04-29T12:50:36Z")

</div>

I am trying to use an external library that has recently started providing Config.cmake files for itself. Before this, cmake was providing a Find.cmake module for this library. The library provides an imported target that I can use in my cmake files, which is desired. The module Find does not.

Is there anyway I can tell cmake to ignore the Find.cmake file and only use the config scripts, so I can rely on using the imported target in my target\_link\_libraries() call?

Interestingly, when I provide a HINT to the find\_package() call, cmake pulls in the imported target. Providing that same path in the CMAKE\_PREFIX\_PATH but omitting it from the find\_package() does not pull in the target.

I’m not sure if this is a bug in cmake or a bug in the Find.cmake file.

Any thoughts on how to rectify this?

---

<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 29, 2021, 5:41pm UTC](https://discourse.cmake.org/t/ignoring-cmakes-delivered-find-package-cmake-to-favor-external-librarys-config-cmake/3236/2 "2021-04-29T17:41:34Z")

</div>

You can pass `CONFIG` to `find_package` to prefer the config file (it will use `FindFoo` if possible; `NO_MODULE` can be used instead to force usage of a config file).

Which package started doing this? We can update `FindFoo.cmake` in CMake to:

- chain off to the config file if available
- provide a compatible (ish?) imported target when it does the work.

---

<div class="post-metadata">

### Author: ![scivision](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/s/a87d85/32.png) [@scivision](https://discourse.cmake.org/u/scivision)
#### Post date: [April 30, 2021, 4:59pm UTC](https://discourse.cmake.org/t/ignoring-cmakes-delivered-find-package-cmake-to-favor-external-librarys-config-cmake/3236/3 "2021-04-30T16:59:17Z")

</div>

HINT and several other find\_package options implicitly put find\_package into Config mode, which is why you see that behavior

---

<div class="post-metadata">

### Author: ![brentd](https://discourse.cmake.org/user_avatar/discourse.cmake.org/brentd/32/3596_2.png) [@brentd](https://discourse.cmake.org/u/brentd)
#### Post date: [April 30, 2021, 5:48pm UTC](https://discourse.cmake.org/t/ignoring-cmakes-delivered-find-package-cmake-to-favor-external-librarys-config-cmake/3236/4 "2021-04-30T17:48:51Z")

</div>

Thanks for the responses! Forcing CONFIG mode fixed my problem.

The package I was referring to was Armadillo.

---

<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 30, 2021, 5:58pm UTC](https://discourse.cmake.org/t/ignoring-cmakes-delivered-find-package-cmake-to-favor-external-librarys-config-cmake/3236/5 "2021-04-30T17:58:08Z")

</div>

Please file an issue to enhance `FindArmadillo` for this new upstream behavior.
