Skip to content

Commit 111cc44

Browse files
committed
cmake: guard OpenSSL find when imported targets already provided
Wrap find_package(OpenSSL) in a conditional to avoid resolving host libraries when prebuilt OpenSSL::SSL/OpenSSL::Crypto targets are injected (Android embedding). pthread linking remains skipped on Android where pthread is part of libc.
1 parent 7fbbcbb commit 111cc44

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,11 @@ if(LIBCORO_FEATURE_NETWORKING)
150150
)
151151

152152
if(LIBCORO_FEATURE_TLS)
153-
find_package(OpenSSL REQUIRED)
153+
# Android embedding: if caller already defined imported targets OpenSSL::SSL and OpenSSL::Crypto
154+
# (e.g. prebuilt static libs), skip find_package to avoid accidentally picking host libs.
155+
if (NOT (TARGET OpenSSL::SSL AND TARGET OpenSSL::Crypto))
156+
find_package(OpenSSL REQUIRED)
157+
endif()
154158
list(APPEND LIBCORO_SOURCE_FILES
155159
include/coro/net/tls/client.hpp src/net/tls/client.cpp
156160
include/coro/net/tls/connection_status.hpp src/net/tls/connection_status.cpp

0 commit comments

Comments
 (0)