# find\_package in external project

**URL:** <https://discourse.cmake.org/t/find-package-in-external-project/4771>\
**Category:** Code\
**Created:** [January 4, 2022, 10:49am UTC](https://discourse.cmake.org/t/find-package-in-external-project/4771 "2022-01-04T10:49:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![cmak](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/c/eb8c5e/32.png) [@cmak](https://discourse.cmake.org/u/cmak)\
**Post date:** [January 4, 2022, 10:49am UTC](https://discourse.cmake.org/t/find-package-in-external-project/4771/1 "2022-01-04T10:49:25Z")

</div>

Is it possible to use `find_package` from a component that is built as an external project?

I believe `find_package` is executed at configure time, but the cmake files required for `find_package` are installed when external project is built. Want to avoid building external project at configure time.

---

<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:** [January 4, 2022, 5:19pm UTC](https://discourse.cmake.org/t/find-package-in-external-project/4771/2 "2022-01-04T17:19:14Z")

</div>

I believe you want `FetchContent`, not `ExternalProject`. Using `ExternalProject_add` in the same build as `add_library` trying to consume those bits doesn’t work well. You can do `ExternalProject_add` for your code to make everything use `ExternalProject` as an alternative.

---

<div class="post-metadata">

**Author:** ![cmak](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/c/eb8c5e/32.png) [@cmak](https://discourse.cmake.org/u/cmak)\
**Post date:** [January 4, 2022, 6:20pm UTC](https://discourse.cmake.org/t/find-package-in-external-project/4771/3 "2022-01-04T18:20:53Z")

</div>

I thought `FetchContent` only downloads at configure time (i.e. no build at configure time)? For the `find_package` to succeed, the external software has to be built and installed.

Two `ExternalProject_add` with `DEPENDS` might work, but a bit clumsy as there is really only one external (3pp) software to be built (don’t want to build my native software as an external).

---

<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:** [January 5, 2022, 2:21am UTC](https://discourse.cmake.org/t/find-package-in-external-project/4771/4 "2022-01-05T02:21:09Z")

</div>

The “everything is external” is known as a “superbuild” and is basically a packaging setup in miniature. Each build is, itself, independent, but is just built as part of a larger whole. If you want `find_package` to work, you’ll need something like this to order the build and installation against each other.
