Hello, Related to my recent crash report and its fix https://gitlab.kitware.com/cmake/cmake/merge_requests/3071 I struggle with exporting an imported target and according to the commit message it seems I will not be able to do that.
Use case: · Tree1 needs an external lib libextlib.so from /path/to/lib which is not a system path. Thus Tree1 creates an imported target "extlib" of it · Tree1 provides a library "lib1", links it to "extlib" and installs+exports "lib1" · Tree2 imports Tree1 export file and tries to make "myexe" which would link to "lib1". Which is fine. · Problem: linker for "myexe" needs to link to the soname of "extlib", e.g. libextlib.so.1 and it cannot find it because it is not in a system path · Solution1: Add /path/to/lib as a link_directory in Tree2. I dislike the solution as Tree2 should not need to know this · Solution2: Try to get /path/to/lib inherited in target properties all the way from "extlib" -> "lib1" -> "myexe" using target_link_directories. This fails due to those directories passed to linker via -L which is not used to find library _dependencies_ · Solution3: Add -rpath-link /path/to/lib with target_link_options to "extlib" in Tree1 so that it would get inherited all the way to "myexe". It does not seem to inherit if "lib1" links to "extlib" in PRIVATE mode. Thus I need to link it "PUBLIC" which would require me to export the imported target "extlib". o If I do not install the target "extlib", I see no way to place it in the "export set" which makes the install of "lib1" to fail due to their PUBLIC linkage 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? -Lassi Niemistö
-- 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