How do you integrate an external library to your ROS catkin_Workspace?

So following example: I have Package A with the function doA(); and I have Package B inside my catkin_ws. Now If I want to use doA(); in package B I would add the following to the package.xml of B: <depend>A</depend> and it works.

Now the case with an external library: So lets assume my Package A needs an external library outside of my catkin_workspace. For example something in /home/tom/lib/. Now I link this external library to my Package A by changing the CMakeLists.txt:

find_library(EX_LIB el HINT /home/tom/lib/)
target_link_libraries(A $${EX_LIB}) target_link_libraries(test_A$${PROJECT_NAME}
\${EX_LIB})


No when I try to run doA(); in Package B it will not work. The dependency in the package.xml is not enough, I have to link the external Library in the CMakeLists.txt of B too. Why? And how can I integrate that external library the right way into my catkin_ws, so I do not have to link it in every package that uses Package A.

Edit: I think my problem is similar to this:ROS-External-Wrapper , but in my case I do not have the source files only the prebuilt libraries.

Adding a dependency to the package.xml allows rosdep to resolve dependencies prior to building, as well as provides a list of dependencies but that doesn't provide any information about the contents of the package such as the libraries to link against.
For native catkin packages they use the catkin_package macro to export flags which can be leveraged automatically by downstream packages. Here's a related question Catkin packages leverage those exports to make things more automatic. However for your "external" project those helper exports are not available. These are not magic either, they come from the CATKIN_DEPENDS too.
If you're writing a library in A (libA) that needs to link against your external library at runtime, and then trying to link against libA from package B you need to add to the CMake for libA to export the dependency on your EX_LIB.