How to manage hierarchical dependencies ?

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 ?

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