This is an automated email from the ASF dual-hosted git repository.
bneradt 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 979de0abf2 Fix OpenSSL dependency tree for CMake build (#10078)
979de0abf2 is described below
commit 979de0abf2cd4a370385851c8ff712f49a656d57
Author: JosiahWI <[email protected]>
AuthorDate: Mon Jul 24 10:58:40 2023 -0500
Fix OpenSSL dependency tree for CMake build (#10078)
This removes the global dependency on OpenSSL libraries by specifying
them per target. This avoids linking some targets against OpenSSL that
do not need it and helps clean up the dependency tree.
---
CMakeLists.txt | 7 +------
iocore/eventsystem/CMakeLists.txt | 2 --
iocore/net/CMakeLists.txt | 3 ++-
iocore/net/quic/CMakeLists.txt | 3 ++-
plugins/cache_promote/CMakeLists.txt | 2 ++
plugins/certifier/CMakeLists.txt | 6 ++++++
plugins/lua/CMakeLists.txt | 6 +++++-
plugins/prefetch/CMakeLists.txt | 6 +++++-
plugins/s3_auth/CMakeLists.txt | 2 +-
plugins/s3_auth/unit_tests/CMakeLists.txt | 2 +-
proxy/http/CMakeLists.txt | 1 +
src/traffic_layout/CMakeLists.txt | 7 +------
src/tscore/CMakeLists.txt | 15 ++++++++++-----
src/wccp/CMakeLists.txt | 8 +++++++-
tests/gold_tests/chunked_encoding/CMakeLists.txt | 2 +-
15 files changed, 45 insertions(+), 27 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 67ef9ea530..9cc4d1e237 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -182,7 +182,7 @@ endif()
find_package(PCRE REQUIRED)
include(CheckOpenSSLIsBoringSSL)
-find_package(OpenSSL)
+find_package(OpenSSL REQUIRED)
check_openssl_is_boringssl(OPENSSL_IS_BORINGSSL "${OPENSSL_INCLUDE_DIR}")
if(OPENSSL_VERSION VERSION_GREATER_EQUAL "3.0.0")
@@ -328,11 +328,6 @@ include_directories(
${CMAKE_BINARY_DIR}/include
)
-if (OPENSSL_FOUND)
- include_directories(${OPENSSL_INCLUDE_DIR})
- link_libraries(${OPENSSL_CRYPTO_LIBRARY})
-endif(OPENSSL_FOUND)
-
add_subdirectory(lib)
# Keep this after lib because lib is made up of third party libraries, so if
diff --git a/iocore/eventsystem/CMakeLists.txt
b/iocore/eventsystem/CMakeLists.txt
index 1a39cc1a90..aa0c3fc0fe 100644
--- a/iocore/eventsystem/CMakeLists.txt
+++ b/iocore/eventsystem/CMakeLists.txt
@@ -45,8 +45,6 @@ target_link_libraries(inkevent
ts::tscore
PRIVATE
libswoc
- ${OPENSSL_LIBRARIES} # transitive
- PCRE::PCRE # transitive
resolv # transitive
tscpputil # transitive
yaml-cpp::yaml-cpp # transitive
diff --git a/iocore/net/CMakeLists.txt b/iocore/net/CMakeLists.txt
index 86f8c0a351..d5989d6494 100644
--- a/iocore/net/CMakeLists.txt
+++ b/iocore/net/CMakeLists.txt
@@ -113,7 +113,6 @@ target_include_directories(inknet PUBLIC
${CMAKE_SOURCE_DIR}/proxy/http
${CMAKE_SOURCE_DIR}/proxy/http/remap
${CMAKE_SOURCE_DIR}/src/traffic_server
- ${OPENSSL_INCLUDE_DIRS}
${YAML_INCLUDE_DIRS}
)
@@ -122,6 +121,8 @@ target_link_libraries(inknet
ts::inkevent
ts::records
ts::tscore
+ OpenSSL::Crypto
+ OpenSSL::SSL
)
# Fails to link because of circular dep with proxy (ParentSelection)
diff --git a/iocore/net/quic/CMakeLists.txt b/iocore/net/quic/CMakeLists.txt
index 73ed59206a..15b1e1e25d 100644
--- a/iocore/net/quic/CMakeLists.txt
+++ b/iocore/net/quic/CMakeLists.txt
@@ -39,7 +39,8 @@ target_link_libraries(quic
PUBLIC
inkevent
inknet
- ${OPENSSL_LIBRARY}
quiche::quiche
ts::tscore
+ OpenSSL::Crypto
+ OpenSSL::SSL
)
diff --git a/plugins/cache_promote/CMakeLists.txt
b/plugins/cache_promote/CMakeLists.txt
index f3c3638de8..f331ffaf6f 100644
--- a/plugins/cache_promote/CMakeLists.txt
+++ b/plugins/cache_promote/CMakeLists.txt
@@ -22,3 +22,5 @@ add_atsplugin(cache_promote
lru_policy.cc
policy_manager.cc
)
+
+target_link_libraries(cache_promote PRIVATE OpenSSL::Crypto)
diff --git a/plugins/certifier/CMakeLists.txt b/plugins/certifier/CMakeLists.txt
index 6495cfeb9e..fb9128183d 100644
--- a/plugins/certifier/CMakeLists.txt
+++ b/plugins/certifier/CMakeLists.txt
@@ -16,3 +16,9 @@
#######################
add_atsplugin(certifier certifier.cc)
+
+target_link_libraries(certifier
+ PRIVATE
+ OpenSSL::Crypto
+ OpenSSL::SSL
+)
diff --git a/plugins/lua/CMakeLists.txt b/plugins/lua/CMakeLists.txt
index d0e224f1f4..6f060eaca5 100644
--- a/plugins/lua/CMakeLists.txt
+++ b/plugins/lua/CMakeLists.txt
@@ -49,4 +49,8 @@ add_atsplugin(tslua
target_include_directories(tslua PRIVATE "${PROJECT_SOURCE_DIR}/include")
-target_link_libraries(tslua PRIVATE LuaJIT::LuaJIT)
+target_link_libraries(tslua
+ PRIVATE
+ LuaJIT::LuaJIT
+ OpenSSL::Crypto
+)
diff --git a/plugins/prefetch/CMakeLists.txt b/plugins/prefetch/CMakeLists.txt
index 7b121fa8dd..ed42e601e7 100644
--- a/plugins/prefetch/CMakeLists.txt
+++ b/plugins/prefetch/CMakeLists.txt
@@ -30,6 +30,10 @@ add_atsplugin(prefetch
plugin.cc
)
-target_link_libraries(prefetch PRIVATE PCRE::PCRE)
+target_link_libraries(prefetch
+ PRIVATE
+ OpenSSL::Crypto
+ PCRE::PCRE
+)
add_subdirectory(test)
diff --git a/plugins/s3_auth/CMakeLists.txt b/plugins/s3_auth/CMakeLists.txt
index b0b797e711..4f9796c2b7 100644
--- a/plugins/s3_auth/CMakeLists.txt
+++ b/plugins/s3_auth/CMakeLists.txt
@@ -19,6 +19,6 @@ project(s3_auth)
add_atsplugin(s3_auth s3_auth.cc aws_auth_v4.cc)
-target_link_libraries(s3_auth PRIVATE ts::tscore)
+target_link_libraries(s3_auth PRIVATE ts::tscore OpenSSL::Crypto)
add_subdirectory(unit_tests)
diff --git a/plugins/s3_auth/unit_tests/CMakeLists.txt
b/plugins/s3_auth/unit_tests/CMakeLists.txt
index cfbec9eb3a..dfb0184c66 100644
--- a/plugins/s3_auth/unit_tests/CMakeLists.txt
+++ b/plugins/s3_auth/unit_tests/CMakeLists.txt
@@ -20,7 +20,7 @@ add_executable(test_s3_auth
"${PROJECT_SOURCE_DIR}/aws_auth_v4.cc"
)
-target_link_libraries(test_s3_auth PRIVATE catch2::catch2)
+target_link_libraries(test_s3_auth PRIVATE catch2::catch2 OpenSSL::Crypto)
target_compile_definitions(test_s3_auth PRIVATE AWS_AUTH_V4_UNIT_TEST)
diff --git a/proxy/http/CMakeLists.txt b/proxy/http/CMakeLists.txt
index 5a3d88a24d..6c18c26f90 100644
--- a/proxy/http/CMakeLists.txt
+++ b/proxy/http/CMakeLists.txt
@@ -54,6 +54,7 @@ target_include_directories(http
${IOCORE_INCLUDE_DIRS}
${PROXY_INCLUDE_DIRS}
${YAMLCPP_INCLUDE_DIR}
+ OpenSSL::SSL
)
target_link_libraries(http PUBLIC ts::tscore)
diff --git a/src/traffic_layout/CMakeLists.txt
b/src/traffic_layout/CMakeLists.txt
index bbc58f0551..e898d65cba 100644
--- a/src/traffic_layout/CMakeLists.txt
+++ b/src/traffic_layout/CMakeLists.txt
@@ -22,16 +22,11 @@ add_executable(traffic_layout
traffic_layout.cc
)
-target_include_directories(traffic_layout
- PRIVATE
- ${OPENSSL_INCLUDE_DIRS}
-)
-
target_link_libraries(traffic_layout
PRIVATE
ts::inkevent
- ${OPENSSL_LIBRARY}
ts::records
+ OpenSSL::Crypto
yaml-cpp::yaml-cpp
)
diff --git a/src/tscore/CMakeLists.txt b/src/tscore/CMakeLists.txt
index a6219108dd..4c06c0ba05 100644
--- a/src/tscore/CMakeLists.txt
+++ b/src/tscore/CMakeLists.txt
@@ -115,7 +115,12 @@ else()
target_sources(tscore PRIVATE HKDF_openssl.cc)
endif()
-target_link_libraries(tscore PUBLIC PCRE::PCRE)
+target_link_libraries(tscore
+ PUBLIC
+ OpenSSL::Crypto
+ PCRE::PCRE
+)
+
if(TS_USE_POSIX_CAP)
target_link_libraries(tscore PUBLIC cap::cap)
endif()
@@ -164,12 +169,12 @@ add_executable(test_tscore
target_link_libraries(test_tscore
PRIVATE
libswoc
- tscore
+ ts::tscore
yaml-cpp::yaml-cpp
- libswoc
- ${OPENSSL_LIBRARIES}
resolv
- tscpputil
+ ts::tscpputil
+ OpenSSL::Crypto
+ OpenSSL::SSL
)
if(TS_USE_HWLOC)
target_link_libraries(test_tscore PRIVATE hwloc::hwloc)
diff --git a/src/wccp/CMakeLists.txt b/src/wccp/CMakeLists.txt
index 82a47f02e6..fb8840c8a1 100644
--- a/src/wccp/CMakeLists.txt
+++ b/src/wccp/CMakeLists.txt
@@ -20,6 +20,12 @@ add_library(wccp SHARED
WccpConfig.cc WccpEndPoint.cc WccpMsg.cc WccpStatic.cc
)
-target_link_libraries(wccp PRIVATE libswoc tscore yaml-cpp::yaml-cpp)
+target_link_libraries(wccp
+ PRIVATE
+ ts::tscore
+ libswoc
+ OpenSSL::Crypto
+ yaml-cpp::yaml-cpp
+)
install(TARGETS wccp)
diff --git a/tests/gold_tests/chunked_encoding/CMakeLists.txt
b/tests/gold_tests/chunked_encoding/CMakeLists.txt
index 386fce29fd..e19d711566 100644
--- a/tests/gold_tests/chunked_encoding/CMakeLists.txt
+++ b/tests/gold_tests/chunked_encoding/CMakeLists.txt
@@ -17,7 +17,7 @@
add_executable(smuggle-client smuggle-client.c)
-target_link_libraries(smuggle-client PRIVATE "${OPENSSL_SSL_LIBRARY}")
+target_link_libraries(smuggle-client PRIVATE OpenSSL::SSL)
set_property(
TARGET smuggle-client