Creating binary with CMake removes runtime path

后端 未结 3 1997
小蘑菇
小蘑菇 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:48

    This works for CMake 2.8

     set_target_properties(foo PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE)
    

    where foo is the target you defined earlier:

     project(foo)
     add_executable(foo ...)
      ...
     install(TARGETS foo DESTINATION bin)
      ...
    

    Before

    % sudo make install
    Install the project...
    -- Install configuration: ""
    -- Installing: /opt/mystuff/bin/foo
    -- Removed runtime path from "/opt/mystuff/bin/foo"
    

    After

    % sudo make install
    Install the project...
    -- Install configuration: ""
    -- Installing: /opt/mystuff/bin/foo
    -- Set runtime path of "/opt/mystuff/bin/foo" to "/opt/zzyzx/lib:/opt/bar/lib/x86_64"
    

提交回复
热议问题