diff options
author | Guy Harris <gharris@sonic.net> | 2022-09-25 14:35:38 -0700 |
---|---|---|
committer | Guy Harris <gharris@sonic.net> | 2022-10-10 00:35:40 -0700 |
commit | bdc64c66fb6fd5eebcef5990438536cce7f1eb54 (patch) | |
tree | 5b99345beada9191dec3233d56fd46ef96188265 /CMakeLists.txt | |
parent | 131eff83c732ebcecec7ae5d1d36fe061be31c7a (diff) | |
download | tcpdump-bdc64c66fb6fd5eebcef5990438536cce7f1eb54.tar.gz |
cmake: prevent stripping of the rpath on installation.
This should fix issue #1008.
(cherry picked from commit dcfed11c0baaa95085b51772439f67f09704402c)
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 775ff4b7..b0760d3d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,6 +28,46 @@ if(POLICY CMP0074) cmake_policy(SET CMP0074 NEW) endif() +# +# OK, this is a pain. +# +# When building on NetBSD, with a libpcap installed from pkgsrc, +# a -Wl,-rpath,/usr/pkg/lib option is added to the options when +# linking tcpdump. This puts /usr/pkg/lib into the run-time path. +# +# However, by default, CMake adds a rule to the install CMake script +# a CMake command (using an undocumented subcommand of file()) that +# strips /usr/pkg/lib *out* of the run-time path; the message in the +# output for the "install" target is +# +# -- Set runtime path of "{target-directory}/tcpdump" to "" +# +# I am not certain what the rationale is for doing this, but a +# *consequence* of this is that, when you run the installed tcpdump, +# it fails to find libpcap.so: +# +# $ {target-directory}/tcpdump -h +# {target-directory}/tcpdump: Shared object "libpcap.so.0" not found +# +# We suppress this by setting CMAKE_INSTALL_RPATH_USE_LINK_PATH to TRUE; +# as the documentation for that variable says: +# +# Add paths to linker search and installed rpath. +# +# CMAKE_INSTALL_RPATH_USE_LINK_PATH is a boolean that if set to True +# will append to the runtime search path (rpath) of installed +# binaries any directories outside the project that are in the linker +# search path or contain linked library files. The directories are +# appended after the value of the INSTALL_RPATH target property. +# +# If, for whatever reason, directories in which we search for external +# libraries, other than the standard system library directories, are +# added to the executable's rpath in the build process, we most +# defintely want them in the installed image's rpath if they are +# necessary in order to find the libraries at run time. +# +set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) + set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules) # |