On 3/8/19 1:11 AM, Lassi Niemistö wrote: > Am I just missing something and should be able to install the export > of “extlib” without installing the target itself? Any reasoning why > imported targets should not be possible to export? Any other solution > ideas for passing the custom link dir of imported lib nicely from tree to > tree?
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. -Brad -- 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