> For your use case, CMake does have logic to generate -rpath-link flags to > find dependencies of linked shared libraries, but it needs to know about > these dependencies.
> Here is how to handle this: > * Tree1 creates an imported target `extlib`. > It is *not* installed or exported. > * Tree1 creates, exports, and installs, `lib1.so` with a dependency > on `libextlib.so.1`. This creates a `Tree1Targets.cmake` file. > Tree1 should also provide a `Tree1Config.cmake` file that includes > the targets file. See > https://cmake.org/cmake/help/v3.14/manual/cmake-packages.7.html#creating-a-package-configuration-file > * Tree1Config.cmake *also* creates imported target `extlib`. > This will be loaded in the context of dependents. > * Tree2 does `find_package(Tree1)`. This loads `Tree1Config.cmake` > which brings in both `extlib` and `lib1`. Now the -rpath_link flag > can be created by CMake. I cannot see any automatic rpath-link generation if I try the above. Should I? If I instead continue to add it manually with target_link_options to extlib, I would still need to link extlib in INTERFACE mode to lib1 to get those link options propagated, which again prevents me from exporting lib1 since extlib is not in the "export set". -Lassi -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: https://cmake.org/mailman/listinfo/cmake-developers