aboutsummaryrefslogtreecommitdiffstats
path: root/wsutil/CMakeLists.txt
diff options
context:
space:
mode:
authorJoão Valverde <j@v6e.pt>2023-01-25 21:41:55 +0000
committerJoão Valverde <j@v6e.pt>2023-02-12 19:20:18 +0000
commit8dfe8737c554b4e4b2b48b994290a75c261e0f11 (patch)
treeb955d56c37ae628c8c1f87233c5ec988ad587e2e /wsutil/CMakeLists.txt
parent877498ad0b027fbcc844509364c9183aa0440030 (diff)
Enable rpathification and working relocation on Linux (take 2)
Dumpcap depends on wsutil.so. The path to the shared library is encoded in the RPATH (or RUNPATH) property of ELF binaries. This is currently an absolute path on most Unixy systems. Dumpcap could not be made to work with a relative RPATH because it uses elevated privileges and some loaders will ignore relative RPATHs and non-standard paths under those circumstances, because of (justified) security concerns. To enable relocation of the program we link dumpcap statically with wsutil instead. This provides a fully working relocatable installation on Linux and other platforms that support relative RPATHs.
Diffstat (limited to 'wsutil/CMakeLists.txt')
-rw-r--r--wsutil/CMakeLists.txt39
1 files changed, 39 insertions, 0 deletions
diff --git a/wsutil/CMakeLists.txt b/wsutil/CMakeLists.txt
index 77354ffb32..eeb39eea42 100644
--- a/wsutil/CMakeLists.txt
+++ b/wsutil/CMakeLists.txt
@@ -406,6 +406,45 @@ install(FILES ${WSUTIL_PUBLIC_HEADERS}
EXCLUDE_FROM_ALL
)
+add_library(wsutil_static STATIC
+ ${WSUTIL_FILES}
+)
+
+target_compile_definitions(wsutil_static PRIVATE
+ ENABLE_STATIC
+ BUILD_WSUTIL
+)
+
+target_link_libraries(wsutil_static
+ PUBLIC
+ ${GLIB2_LIBRARIES}
+ PRIVATE
+ ${GMODULE2_LIBRARIES}
+ ${APPLE_CORE_FOUNDATION_LIBRARY}
+ ${CMAKE_DL_LIBS}
+ ${GCRYPT_LIBRARIES}
+ ${GNUTLS_LIBRARIES}
+ ${ZLIB_LIBRARIES}
+ ${PCRE2_LIBRARIES}
+ ${WIN_IPHLPAPI_LIBRARY}
+ ${WIN_WS2_32_LIBRARY}
+)
+
+target_include_directories(wsutil_static SYSTEM
+ PUBLIC
+ ${GLIB2_INCLUDE_DIRS}
+ ${GCRYPT_INCLUDE_DIRS}
+ ${GNUTLS_INCLUDE_DIRS}
+ PRIVATE
+ ${GMODULE2_INCLUDE_DIRS}
+ ${ZLIB_INCLUDE_DIRS}
+ ${PCRE2_INCLUDE_DIRS}
+)
+
+if(NOT VCSVERSION_OVERRIDE)
+ add_dependencies(wsutil_static vcs_version)
+endif()
+
add_executable(wmem_test EXCLUDE_FROM_ALL wmem/wmem_test.c ${WMEM_FILES})
target_link_libraries(wmem_test wsutil)