Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between CMAKE_INSTALL_PREFIX and CMAKE_INSTALL_RPATH

Tags:

cmake

I have a difficult time in understanding the difference between CMAKE_INSTALL_PREFIX and CMAKE_INSTALL_RPATH.

If I understand well, CMAKE_INSTALL_PREFIX is the prefixed directory that will be installed. Therefore, if I use the following script for installation:

project(hello)
add_library(hello hello.h hello.cpp)
set(CMAKE_INSTALL_PREFIX "c:/ABC/DEF")
INSTALL(TARGETS hello EXPORT hello_export
            RUNTIME DESTINATION bin
            LIBRARY DESTINATION bin
            ARCHIVE DESTINATION lib
            FRAMEWORK DESTINATION bin
            INCLUDES  DESTINATION include
            )

Then the static library will be installed in C:/ABC/DEF/lib.

Then, my question is what's the point of using CMAKE_INSTALL_RPATH?

like image 671
feelfree Avatar asked Aug 17 '15 10:08

feelfree


1 Answers

On a system which supports paths of the form c:/ABC/DEF (i.e. Windows), none. Windows binaries don't have a notion of rpath.

On systems which do have DT_RPATH and DT_RUNPATH (= those which use ELF binaries), the CMake variable CMAKE_INSTALL_RPATH is used to set up the value of DT_RPATH (or DT_RUNPATH) tags which will be written into the binaries at installation.

like image 129
Angew is no longer proud of SO Avatar answered Jun 09 '23 21:06

Angew is no longer proud of SO