# Install an external project BEFORE configuring subdirs

**URL:** <https://discourse.cmake.org/t/install-an-external-project-before-configuring-subdirs/5709>\
**Category:** Code\
**Created:** [May 23, 2022, 6:52am UTC](https://discourse.cmake.org/t/install-an-external-project-before-configuring-subdirs/5709 "2022-05-23T06:52:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hameer\_Spire](https://discourse.cmake.org/user_avatar/discourse.cmake.org/hameer_spire/32/2442_2.png) [@Hameer\_Spire](https://discourse.cmake.org/u/Hameer_Spire)\
**Post date:** [May 23, 2022, 6:52am UTC](https://discourse.cmake.org/t/install-an-external-project-before-configuring-subdirs/5709/1 "2022-05-23T06:52:47Z")

</div>

Hello! I’m using `xtensor` and `xtensor-python` in my projects. I’d like it very much if I could somehow pecify that these need to be installed before my project is configured. I’d also like to do this superbuild-style, like in `FetchContent`, since these are header-only.

---

<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:** [May 23, 2022, 1:51pm UTC](https://discourse.cmake.org/t/install-an-external-project-before-configuring-subdirs/5709/2 "2022-05-23T13:51:22Z")

</div>

Note that `ExternalProject_add` doesn’t mix well with `add_library` (i.e., if you use `EP_add` for your dependencies, you should also build your project that way). But I think `FetchContent` is as close as you can get otherwise.

Cc: @craig.scott

---

<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:** [May 23, 2022, 10:20pm UTC](https://discourse.cmake.org/t/install-an-external-project-before-configuring-subdirs/5709/3 "2022-05-23T22:20:30Z")

</div>

If they are header-only, do you actually need to install them? If you are already using FetchContent, the question is whether those projects define the same targets as when you have them installed and find them with `find_package()` instead. If they do define the same targets, then you should be fine using FetchContent to bring them into the main build. You’d have to provide more details about what you tried and what didn’t work to be able to help you any further.

---

<div class="post-metadata">

**Author:** ![Hameer\_Spire](https://discourse.cmake.org/user_avatar/discourse.cmake.org/hameer_spire/32/2442_2.png) [@Hameer\_Spire](https://discourse.cmake.org/u/Hameer_Spire)\
**Post date:** [May 24, 2022, 5:57am UTC](https://discourse.cmake.org/t/install-an-external-project-before-configuring-subdirs/5709/4 "2022-05-24T05:57:33Z")

</div>

The problem is `ProjectConfig.cmake` only exists after an installation, and all the targets are defined there.

> <https://github.com/xtensor-stack/xtensor/blob/master/xtensorConfig.cmake.in>

As well as:

> <https://github.com/xtensor-stack/xtensor/blob/master/CMakeLists.txt#L267-L269>
