Open donlk opened 3 weeks ago
Hi @donlk
Thanks for your question.
In theory the CMakeDeps
has a provision for making this work, see https://github.com/conan-io/conan/blob/f357f8169c1e4ecf2bee5ca0b5fb723fc36d82b0/conan/tools/cmake/cmakedeps/templates/target_configuration.py#L112
The definition of INTERFACE_LINK_DIRECTORIES
should result in CMake defining the -Wl,-rpath-link
automatically.
It is true that in some cases, the way visibility is defined, it could require doing target_link_libraries(mytarget PUBLIC dep_target::dep_target)
as defining it as private might disable the -rpath-link
thing. Maybe you can check and try this. If it is not this, I'd suggest trying to post a fully reproducible (and as minimal as possible) example, so we can check it too. Thanks!
Thanks for the response.
Directly going into each lib's CMake scripts and redefining target_link_libraries
kind of defeats the purpose of conan in this instance. I've read about it in an other issue of how difficult it is to solve, so not blaming anyone here, I was just a bit frustrated.
EDIT: Btw, these libs mostly used Autotools instead of CMake, don't now if Autotools even differentiates between public and private linking.
Thanks again, I'll leave it up to you to close the issue if no further input is needed from me.
Duplicate of https://github.com/conan-io/conan/issues/13560 I think.
What is your question?
Hi! So I've been struggling with this issue for quite some time, living with it, but eventually it bothered me enough to post about it here.
Scenario: Given a library (in my case
mesa
) is built as shared through conan. It has a bunch of deps, such as X11 and libxcb, built also as shared, as recommended.Now, whenever
mesa
is used by some other conanfile (for simplicity, let's say the other conanfile is it's own test_package), and libGL.so is linked, the linker fails, as it's unable to find it's transitive deps:All of these libs are build through conan and described in mesa's
package_info
:Weird thing is,
libglapi.so.0
is in the same place aslibGL.so
, so even that fails as$ORIGIN
is not set in the rpath.I've been digging into other issues describing something similar, but I haven't found a solution that's not hacky in some way. I've come up with supplying
-Wl,rpath
directly through the parent's conanfile:In theory conan should take care of this through the
VirtualBuildEnv
andVirtualRunEnv
generators, while CMake can rely onCMakeDeps
, yetrpath-link
is not supplied. One thing I've noticed is the generatedconanrunenv-release-x86_64.sh
file hasLD_LIBRARY_PATH
set with the correct values for runtime use-cases:However,
conanbuildenv-release-x86_64.sh
does not define these paths as rpath-links. Is this intentional?This happens with other libraries built as shared.
Am I missing something? Thank you!
Have you read the CONTRIBUTING guide?