This is an automated email from the ASF dual-hosted git repository.
cmcfarlen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new 31c15927e6 Make linking libraries to plugins optional (#11039)
31c15927e6 is described below
commit 31c15927e66c30566edf5e0e83c6b1bf39e84288
Author: Chris McFarlen <[email protected]>
AuthorDate: Mon Feb 26 17:19:31 2024 -0600
Make linking libraries to plugins optional (#11039)
* Make linking libraries to plugins optional
* Also check for shared libs before linking libs to plugins
---------
Co-authored-by: Chris McFarlen <[email protected]>
---
CMakeLists.txt | 1 +
cmake/add_atsplugin.cmake | 9 ++++++++-
plugins/experimental/maxmind_acl/CMakeLists.txt | 2 +-
3 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d5bb5f1fb5..63ec25723a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -138,6 +138,7 @@ option(ENABLE_AUTEST "Setup autest (default OFF)")
option(ENABLE_BENCHMARKS "Build benchmarks (default OFF)")
option(EXTERNAL_YAML_CPP "Use external yaml-cpp (default OFF)")
option(EXTERNAL_LIBSWOC "Use external libswoc (default OFF)")
+option(LINK_PLUGINS "Link core libraries to plugins (default OFF)")
# Setup user
# NOTE: this is the user trafficserver runs as
diff --git a/cmake/add_atsplugin.cmake b/cmake/add_atsplugin.cmake
index 61b3c4a914..80de5bb965 100644
--- a/cmake/add_atsplugin.cmake
+++ b/cmake/add_atsplugin.cmake
@@ -19,7 +19,14 @@ set(CMAKE_SHARED_LIBRARY_PREFIX "")
function(add_atsplugin name)
add_library(${name} MODULE ${ARGN})
- target_link_libraries(${name} PRIVATE ts::tsapi ts::tsutil)
+ if(LINK_PLUGINS AND BUILD_SHARED_LIBS)
+ target_link_libraries(${name} PRIVATE ts::tsapi ts::tsutil)
+ else()
+ target_include_directories(
+ ${name} PRIVATE "$<TARGET_PROPERTY:libswoc::libswoc,INCLUDE_DIRECTORIES>"
+
"$<TARGET_PROPERTY:yaml-cpp::yaml-cpp,INCLUDE_DIRECTORIES>"
+ )
+ endif()
set_target_properties(${name} PROPERTIES PREFIX "")
set_target_properties(${name} PROPERTIES SUFFIX ".so")
remove_definitions(-DATS_BUILD) # remove the ATS_BUILD define for plugins to
build without issue
diff --git a/plugins/experimental/maxmind_acl/CMakeLists.txt
b/plugins/experimental/maxmind_acl/CMakeLists.txt
index 0ce160a7f6..0b736718ed 100644
--- a/plugins/experimental/maxmind_acl/CMakeLists.txt
+++ b/plugins/experimental/maxmind_acl/CMakeLists.txt
@@ -20,7 +20,7 @@ if(maxminddb_FOUND)
add_atsplugin(maxmind_acl maxmind_acl.cc mmdb.cc)
target_link_libraries(
- maxmind_acl PRIVATE libswoc::libswoc ts::tscore ts::tsutil
yaml-cpp::yaml-cpp maxminddb::maxminddb PCRE::PCRE
+ maxmind_acl PRIVATE libswoc::libswoc ts::tsapi ts::tsutil
yaml-cpp::yaml-cpp maxminddb::maxminddb PCRE::PCRE
)
else()