I use the following CMake commands to create a library B:
find_package(A REQUIRED) add_library(B SHARED a.c b.c) target_link_libraries(B PUBLIC A::alib)