I'm trying to link a cmake build with two shared libraries, linking occurs but RPATH
is pointing to an absolute path of one of the two libraries while readelf
output is incorrect for the other.
What I did is the following:
add_library(foo SHARED IMPORTED)
set_target_properties(foo
PROPERTIES IMPORTED_LOCATION ${LIBS_DIRECTORY}/foo/libfoo.so
)
add_library(bar SHARED IMPORTED)
set_target_properties(bar
PROPERTIES IMPORTED_LOCATION ${LIBS_DIRECTORY}/foo/libbar.so
)
target_link_libraries(myprogram foo bar)
This works and linking occurs but readelf prints the following:
0x0000000000000001 (NEEDED) Shared library: [../../../libs/foo/libfoo.so]
0x0000000000000001 (NEEDED) Shared library: [libbar.so]
0x000000000000000f (RPATH) Library rpath: [/home/user/test/trunk/libs/foo:/home/user/test/trunk/libs/bar]
So basically one of the two libs (but just one, and it makes no sense) has an absolute path while rpath contains both the full paths (which is not what I want to do, since I want to ship the executable with the two libraries in the same folder of the exectuable (or a subfolder at most).
Am I missing something trivial?