I think instead of working with multiple target_*
commands, you should use find_package()
and use IMPORTED
targets. That will save you a lot of calls and variable shuffling.
I suspect that your main issue is that everything is using PRIVATE
visibility. Instead, each usage should have an associated visibility:
target_link_libraries_wrapper(my_libA
PUBLIC EXTERNAL_LIB_PNG)
Another thing you can do is make your own targets that “encapsulate” each external dependency:
find_package(PNG REQUIRED)
add_library(external_png INTERFACE)
target_link_libraries(external_png INTERFACE PNG::PNG)
# …
target_link_libraries(my_libA PUBLIC external_png)
which wouldn’t require any wrapper.