Creating binary with CMake removes runtime path

后端 未结 3 1989
小蘑菇
小蘑菇 2021-02-04 01:19

I am using CMake to build a program on linux. The program compiles successfully and runs from the project build directory. The program is linked with a custom library in the dir

3条回答
  •  误落风尘
    2021-02-04 01:57

    Note: if you don't want to modify the cmake scripts themselves, setting property around, you can launch you cmake with a directive asking to not remove the runtime path:
    See "Variables that Control the Build", with variable: "CMAKE_SKIP_RPATH"

    If true, do not add run time path information.

    If this is set to TRUE, then the rpath information is not added to compiled executables.
    The default is to add rpath information if the platform supports it. This allows for easy running from the build tree.
    To omit RPATH in the install step, but not the build step, use CMAKE_SKIP_INSTALL_RPATH instead.

    If the deliveries already contained the right runtime path, that directive will avoid cmake to do any modification to the current runtime path included in said deliveries.

    cmake -DCMAKE_SKIP_RPATH=ON xxx.cmake
    

提交回复
热议问题