[cmake-developers] Exporting an imported target not supported?
Lassi Niemistö
lassi.niemisto at wapice.com
Mon Mar 11 08:50:54 EDT 2019
> 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
More information about the cmake-developers
mailing list