CMAKE RPATH with packaging

こ雲淡風輕ζ 提交于 2019-12-07 06:27:19

问题


I am creating package using cmake

I am having following structure

bin/
    bin1
lib/

    lib1
    lib2

Where lib1 and lib2 are external dynamic library. How can I set RPATH so it will automatically link with lib1 and lib2 ?


回答1:


I've been fussing with cmake on this as well. Cmake uses CMAKE_SKIP_BUILD_RPATH for linking at build time and CMAKE_INSTALL_RPATH to set the rpath used when the install target is built. cmake has some good info on using its rpath mechanism: http://www.cmake.org/Wiki/CMake_RPATH_handling

An alternative method is to use ldconfig. I notice that when you build svn(1.6.17), it's make install target invokes ldconfig to set rpath.

take a look at $ORIGIN as you'll need that in your rpath to keep it relative to the binary rather than relative to $PWD.

Building a simple (hello-world-esque) example of using ld's option -rpath with $ORIGIN




回答2:


AFAIK, CMake automatically adds rpaths to all targets, which you are linking with target_link_libraries().

To switch it off there is CMAKE_SKIP_RPATH option.



来源:https://stackoverflow.com/questions/8401450/cmake-rpath-with-packaging

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