Reputation: 9540
Say I have the following dependency chain, dependency A depends on B which depends on C. All 3 are specified as dep
objects.
The headers of B include headers in C.
I am finding that when I compile A I must list C as an explicit dependency even if B is already listed as a dependency, otherwise C's headers are not available in A's translation units.
How can I instruct meson to automatically include C's headers wherever B is used as a dependency?
Upvotes: 1
Views: 303
Reputation: 8606
You must specify your C dependency with header path included via include_directories
:
c_dep = declare_dependency(
dependencies: c_lib,
include_directories: include_directories(c_inc_dirs),
)
Then add C in your B dependency, like this:
b_deps = []
b_deps += dependency('clib', fallback:['clib', 'c_dep'])
b_dep = declare_dependency(
link_with: b_lib,
include_directories: b_inc_dirs,
dependencies: b_deps)
The A should also add normal dependency to B, and not to C because C is already added in B.
Upvotes: 0
Reputation: 123
I think you need to use declare_dependency
something like this should work.
C_dep = declare_dependency(include_directories : C_includes)
B_dep = declare_dependency(include_directories : B_includes, dependencies : [C_dep])
A_dep = static_library('a_lib', dependencies : [B_dep]) # or whatever your usecase is
Upvotes: 1