add_library( a )
target_sources( a PRIVATE a.c PUBLIC a.h )
add_library( b ) target_sources( b PRIVATE b.c PUBLIC b.h ) target_link_libraries( b PUBLIC a )
When I bring this up in my IDE, target a has headers ‘a.h’, but target b has headers ‘a.h’, ‘b.h’. It seems that all the public sources in a are being imported into the visible space of b.
On the one hand, this is useful if I want to be able to easily view all the headers. But it also means that (in a large project) the headers that belong to b directly get lost among all the headers of all b’s dependencies.
Am I doing something wrong here?
Note that all of a’s headers are already available in my project as source files from a. But CMake makes them appear a second time as source files of b.