Skip to content

Commit

Permalink
Add configure option NO_DEFAULT_RPATH
Browse files Browse the repository at this point in the history
The currently used compiler settings explicitly set RPATH to
installed binaries which is not desired behaviour in some
circumstances, e.g. OpenEmbedded's QA checks report an issue
about redundant RPATH set to the standard '/usr/lib' directory.

This patch adds the configure option NO_DEFAULT_RPATH which is
ON by default in order to preserve the current behaviour, but
when set to OFF make CMake use its default RPATH settings, that is
set RPATH for the binaries in the build tree, but clear them out
for installed binaries.

Signed-off-by: Dmitry Rozhkov <[email protected]>
  • Loading branch information
Dmitry Rozhkov committed Feb 7, 2017
1 parent b05b569 commit 8be2fc6
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions CMakeModules/CompilerSettings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,19 @@ if((CMAKE_COMPILER_IS_GNUCXX OR IS_ICPC) AND NOT MINGW)
endif()
endif()

# By default CMake sets RPATH for binaries in the build tree, but clears
# it when installing. Switch this option off if the default behaviour is
# desired.
option(NO_DEFAULT_RPATH "Set RPATH for installed binaries" ON)

# Set rpath http://www.paraview.org/Wiki/CMake_RPATH_handling
set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_LIBDIR_FULL}")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
if(NO_DEFAULT_RPATH)
message(STATUS "Set RPATH explicitly to '${CMAKE_INSTALL_LIBDIR_FULL}'")
set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_LIBDIR_FULL}")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
endif(NO_DEFAULT_RPATH)

# no prefix needed for python modules
set(CMAKE_SHARED_MODULE_PREFIX "")

0 comments on commit 8be2fc6

Please sign in to comment.