Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds CMAKE_BUILD_WITH_INSTALL_RPATH to RPATH how to #1094

Merged
merged 3 commits into from
Mar 6, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions howtos/manage_shared_libraries/rpaths.rst
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,9 @@ Remember to pass the ``KEEP_RPATHS`` variable to the ``conan_basic_setup``:
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(KEEP_RPATHS)

Then, you could, for example, use the ``@executable_path`` in OSX and ``$ORIGIN`` in Linux to adjust
a relative path from the executable:
Then, you could, for example, use the ``@executable_path`` in OSX and ``$ORIGIN`` in Linux to adjust a relative path from the executable.
Also, enabling `CMAKE_BUILD_WITH_INSTALL_RPATH`_ will build the application with the RPATH value of ``CMAKE_INSTALL_RPATH`` and avoid
the need to be relinked when installed.

.. code-block:: cmake

Expand All @@ -116,6 +117,7 @@ a relative path from the executable:
set(CMAKE_INSTALL_RPATH "$ORIGIN/../lib")
endif()

set(CMAKE_BUILD_WITH_INSTALL_RPATH ON)

You can use this imports statements in the consumer project:

Expand Down Expand Up @@ -146,4 +148,5 @@ And your finally application can follow this layout:
You could move the entire application folder to any location and the shared libraries will be located
correctly.

.. _`CMake RPATH handling`: https://cmake.org/Wiki/CMake_RPATH_handling
.. _`CMake RPATH handling`: https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/RPATH-handling
.. _`CMAKE_BUILD_WITH_INSTALL_RPATH`: https://cmake.org/cmake/help/v3.0/variable/CMAKE_BUILD_WITH_INSTALL_RPATH.html