forked from osmocom/wireshark
CMake: do not set RPATH when installing to a system directory
When built with -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_INSTALL_LIBDIR=lib (as is done by many Linux distributions), do not set an unnecessary RPATH. This was the case before v2.9.0rc0-2727-g697623411c. Relocatable builds will still be possible with the default options as /usr/local/lib is typically not considered a system library path. Change-Id: Ic6ff1760183c20d3f9f9fb787604e888e116534e Reviewed-on: https://code.wireshark.org/review/31602 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: João Valverde <j@v6e.pt> Reviewed-by: Peter Wu <peter@lekensteyn.nl>
This commit is contained in:
parent
91d68d2ec9
commit
5dd86a0a7e
|
@ -180,30 +180,29 @@ include(GNUInstallDirs)
|
||||||
|
|
||||||
# Make sure our executables can can load our libraries if we install into
|
# Make sure our executables can can load our libraries if we install into
|
||||||
# a non-default directory on Unix-like systems other than macOS.
|
# a non-default directory on Unix-like systems other than macOS.
|
||||||
# https://cmake.org/Wiki/CMake_RPATH_handling
|
# https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/RPATH-handling
|
||||||
if(NOT CMAKE_INSTALL_RPATH AND NOT (WIN32 OR APPLE))
|
if(NOT CMAKE_INSTALL_RPATH AND NOT (WIN32 OR APPLE))
|
||||||
# Some systems may have limited or non-existent support for $ORIGIN.
|
# Try to set a RPATH for installed binaries if the library directory is
|
||||||
# https://www.lekensteyn.nl/rpath.html
|
# not already included in the default search list.
|
||||||
set(_enable_rpath_origin 0)
|
list(FIND CMAKE_C_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_FULL_LIBDIR}" IS_SYSTEM_DIR)
|
||||||
if(CMAKE_SYSTEM_NAME MATCHES "^(Linux|SunOS|FreeBSD)$")
|
if(IS_SYSTEM_DIR EQUAL -1)
|
||||||
set(_enable_rpath_origin 1)
|
# Some systems support $ORIGIN in RPATH to enable relocatable
|
||||||
endif()
|
# binaries. In other cases, only absolute paths can be used.
|
||||||
set(ENABLE_RPATH_ORIGIN ${_enable_rpath_origin} CACHE BOOL "Use \$ORIGIN with RPATH")
|
# https://www.lekensteyn.nl/rpath.html
|
||||||
mark_as_advanced(ENABLE_RPATH_ORIGIN)
|
if(CMAKE_SYSTEM_NAME MATCHES "^(Linux|SunOS|FreeBSD)$")
|
||||||
|
set(ENABLE_RPATH_ORIGIN TRUE CACHE BOOL
|
||||||
if(ENABLE_RPATH_ORIGIN)
|
"Use $ORIGIN with INSTALL_RPATH")
|
||||||
# Set an install RPATH relative to the location of the binary, to
|
mark_as_advanced(ENABLE_RPATH_ORIGIN)
|
||||||
# provide a fully relocatable package.
|
else()
|
||||||
set(CMAKE_INSTALL_RPATH "\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}")
|
set(ENABLE_RPATH_ORIGIN FALSE)
|
||||||
# Add the automatically determined parts of the RPATH
|
endif()
|
||||||
# which point to directories outside the build tree to the install RPATH.
|
if(ENABLE_RPATH_ORIGIN)
|
||||||
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
set(CMAKE_INSTALL_RPATH "$ORIGIN/../${CMAKE_INSTALL_LIBDIR}")
|
||||||
else()
|
else()
|
||||||
# Add an absolute RPATH if it is not already included in the
|
|
||||||
# default search list.
|
|
||||||
list(FIND CMAKE_C_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_FULL_LIBDIR}" IS_SYSTEM_DIR)
|
|
||||||
if(IS_SYSTEM_DIR STREQUAL "-1")
|
|
||||||
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_FULL_LIBDIR}")
|
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_FULL_LIBDIR}")
|
||||||
|
endif()
|
||||||
|
# Include non-standard external libraries by default in RPATH.
|
||||||
|
if(NOT DEFINED CMAKE_INSTALL_RPATH_USE_LINK_PATH)
|
||||||
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -46,9 +46,10 @@ macro(set_extcap_executable_properties _executable)
|
||||||
LINK_FLAGS "${WS_LINK_FLAGS}"
|
LINK_FLAGS "${WS_LINK_FLAGS}"
|
||||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/run/extcap
|
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/run/extcap
|
||||||
)
|
)
|
||||||
if(ENABLE_RPATH_ORIGIN)
|
if(CMAKE_INSTALL_RPATH MATCHES "\\$ORIGIN")
|
||||||
|
# Use relative path from ${EXTCAP_INSTALL_LIBDIR} to ${CMAKE_INSTALL_LIBDIR}
|
||||||
set_target_properties(${_executable} PROPERTIES
|
set_target_properties(${_executable} PROPERTIES
|
||||||
INSTALL_RPATH "\$ORIGIN/../.."
|
INSTALL_RPATH "$ORIGIN/../.."
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
if(ENABLE_APPLICATION_BUNDLE)
|
if(ENABLE_APPLICATION_BUNDLE)
|
||||||
|
|
Loading…
Reference in New Issue