# How to manage hierarchical dependencies ?

**URL:** <https://discourse.cmake.org/t/how-to-manage-hierarchical-dependencies/13637>\
**Category:** Code\
**Created:** [February 26, 2025, 8:56am UTC](https://discourse.cmake.org/t/how-to-manage-hierarchical-dependencies/13637 "2025-02-26T08:56:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Oodini](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/o/db5fbb/32.png) [@Oodini](https://discourse.cmake.org/u/Oodini)\
**Post date:** [February 26, 2025, 8:56am UTC](https://discourse.cmake.org/t/how-to-manage-hierarchical-dependencies/13637/1 "2025-02-26T08:56:29Z")

</div>

Hello,

We have some internal pieces of codes we have to organize as **static** library/libraries. This code could be splitted as several libraries, organizes as a hierarchy, or put in only one library.

If tend to choose the first solution, but I’m not sure how to manage that with CMake.

Let the following dependencies, where A is the final client:  
A → B → C  
The dependencies could be retrieved with `FetchContent`.  
But if A retrieves B, it doesn’t know that B depends on C.  
And A could also ask for C.

How to manage that ?

---

<div class="post-metadata">

**Author:** ![noahdav](https://discourse.cmake.org/user_avatar/discourse.cmake.org/noahdav/32/4950_2.png) [@noahdav](https://discourse.cmake.org/u/noahdav)\
**Post date:** [March 13, 2025, 8:23am UTC](https://discourse.cmake.org/t/how-to-manage-hierarchical-dependencies/13637/2 "2025-03-13T08:23:44Z")

</div>

I am not exactly sure what you are asking but I think you are basically asking how to set dependencies. You should use target\_link\_libraries. This will set the libraries that the target depends on. Then if you depend on a target that also sets the target\_link\_libraries this gets resolved. Make sure to look at PUBLIC and INTERFACE as they define how the the dependencies are seen by callers
