-
Notifications
You must be signed in to change notification settings - Fork 991
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[develop2] fixing transitive linux libraries cmake #13010
[develop2] fixing transitive linux libraries cmake #13010
Conversation
@@ -108,6 +108,10 @@ def template(self): | |||
set_property(TARGET {{root_target_name}} | |||
PROPERTY INTERFACE_INCLUDE_DIRECTORIES | |||
$<$<CONFIG:{{configuration}}>:${{'{'}}{{pkg_name}}_INCLUDE_DIRS{{config_suffix}}}> APPEND) | |||
# Necessary to find LINK shared libraries in Linux | |||
set_property(TARGET {{root_target_name}} | |||
PROPERTY INTERFACE_LINK_DIRECTORIES |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit confused - I think this would only solve the problem in some cases, but not all.
If the INTERFACE_LINK_DIRECTORIES
property eventually maps to cmake passing -L
entries to the. linker, the linker documentation (https://linux.die.net/man/1/ld) for -L
states that these only apply to libraries linked via -l
. This is relevant since the linker will not search in -L
directories for "indirect" transitive runtime dependencies that are also not expressed in the linker flags.
That's what -rpath
or -rpath-link
achieves that -L
doesn't (-rpath
works ok when not cross building, -rpath-link
is needed when a sysroot is also passed).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The command for creating app
in my test is:
/usr/bin/cmake -E cmake_link_script CMakeFiles/app.dir/link.txt --verbose=1
/usr/bin/g++ -m64 -O3 -DNDEBUG -m64 CMakeFiles/app.dir/src/app.cpp.o -o app -L"/tmp/tmpbiy1ou19conans/path with spaces/.conan2/p/31071b4017b74cd1/p/lib" -L"/tmp/tmpbiy1ou19conans/path with spaces/.conan2/p/bbd4a1e27c1d25cc/p/lib"
-Wl,-rpath,"/tmp/tmpbiy1ou19conans/path with spaces/.conan2/p/31071b4017b74cd1/p/lib:/tmp/tmpbiy1ou19conans/path with spaces/.conan2/p/bbd4a1e27c1d25cc/p/lib"
"/tmp/tmpbiy1ou19conans/path with spaces/.conan2/p/31071b4017b74cd1/p/lib/libchat.so"
I have isolated the -Wl, -rpath
line, that contains 2 entries, for chat and hello.
Changelog: Fix: Fixing transitive shared linux libraries in CMakeDeps.
Close #13000
There were an issue where building against transitive shared dependencies in Linux (several transitive levels), was failing when this happens in different machines (need to upload & install in a different machine to reproduce), because the linker wants information about the libs, even if not strictly necessary to the final consumer application.
The approach that seems to work is:
self.lib_paths
, onlylibs
to still avoiding direct linking.This might need to extend to components too.