# FetchContent issue finding a fetched project's transitive dependency

**URL:** <https://discourse.cmake.org/t/fetchcontent-issue-finding-a-fetched-projects-transitive-dependency/15163>\
**Category:** Code\
**Created:** [September 11, 2025, 9:30am UTC](https://discourse.cmake.org/t/fetchcontent-issue-finding-a-fetched-projects-transitive-dependency/15163 "2025-09-11T09:30:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tonh](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/t/3bc359/32.png) [@tonh](https://discourse.cmake.org/u/tonh)\
**Post date:** [September 11, 2025, 9:30am UTC](https://discourse.cmake.org/t/fetchcontent-issue-finding-a-fetched-projects-transitive-dependency/15163/1 "2025-09-11T09:30:23Z")

</div>

We have scenario where binary artifacts of a CMake project `Foo` are pulled in through FetchContent. The project has some transitive dependency `Bar` that is bundled within the project. The structure of the binary artifact of Foo is (partly) as follows:

```auto
lib/libfoo.a
lib/libbar.a
lib/cmake/Foo/FooConfig.cmake
lib/cmake/Foo/...etc.
lib/cmake/Bar/BarConfig.cmake
lib/cmake/Bar/...etc.

```

The config file of `Foo` has a `find_dependency(Bar)` call. `Foo` is then pulled in as follows:

```auto
FetchContent_Declare(Foo ...)
FetchContent_MakeAvailable(Foo)

```

This results in the following CMake error:

```auto
CMake Error at /usr/local/.../CMakeFindDependencyMacro.cmake:76 (find_package):By not providing “FindBar.cmake” in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by “Bar”, but CMake did not find one.

```

This is solved by defining in between `FetchContent_Declare` and `FetchContent_MakeAvailable` the following:

```auto
list(PREPEND CMAKE_PREFIX_PATH "${foo_SOURCE_DIR}")

```

Is there a way to solve this in a more canonical way? Ideally, no additional configuration is necessary at the consumer side to be able to depend on `Foo`.
