How to make available files generated by one package that are needed for building another package?


I have two packages that both use CMake build. Let's say Package A and B. B needs some static libraries, headers, scripts and files from A in order to to link and use to generate it's own binary that will eventually be installed in the root filesystem.

From the documentation I gather that, in B's package Makefile I need to list A as a dependency by setting PKG_BUILD_DEPENDS so A gets built first, Also it appears I must use the Build/InstallDev define to install B's artifacts to the staging directory.

I can't quite put this all together and figure out what to write in B's CMakelists.txt so that it can add the libraries it needs from A as dependencies and also refer to the scripts and files it needs from A. I guess the libraries and scripts may go in staging_dir/target-.../usr and it will by default be found by B (using CMAKE_PREFIX_PATH that sets to STAGING_DIR) during build? But what about the files? What's the best place to install such dependincies?

Instead is it easier (and possible) to just reference directly the dependencies from under build_dir/packageB/ in A's Makefile/CMakeLists.txt?