CMake, RPATH, $ORIGIN and @loader_path

本小妞迷上赌 提交于 2020-02-05 07:37:25

问题


In my CMake project I build a bunch of libraries that are loaded at runtime as plugins. I therefore need to set various RPATHs so that these libraries can be found by the dynamic loading mechanism. I also need the whole thing to be relocatable, because it is part of a Python extension module and so gets copied around by various tools during the build process.

It seems that the proper way to do this is to set the RPATH in a relative fashion by using the special $ORIGIN variable on Linux, and @loader_path on OSX. Ok cool, that's fine. But looking through

https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/RPATH-handling

it seems like I have to do this manually? CMake does not have any built-in variable like ${ORIGIN} or something that expands to the correct thing depending on the OS? (and maybe it even varies depending on the linker or something? I have no idea). It just seems like this is the sort of thing that CMake should figure out for me, so I want to check that I'm not missing something before I try to implement the switching myself...

BTW I don't care about Windows, so it doesn't matter if there is some solution that doesn't work for that :).

来源:https://stackoverflow.com/questions/53428219/cmake-rpath-origin-and-loader-path

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!