build: link to Apple frameworks required by static wolfSSL

To fix linking a static wolfSSL library for Apple targets.
Also stop linking `m` and `dl` on Apple platforms.

Matching logic in wolfSSL build code:
8bde512676/CMakeLists.txt (L2520-L2544)

Reported-by: Kai Pastor
Reported-by: Tal Regev
Bug: https://github.com/microsoft/vcpkg/pull/46444#pullrequestreview-3026575393
Ref: https://github.com/microsoft/vcpkg/pull/46444/commits/3a845c4b15066e8167bb4708007180fb6bedf40d

Closes #17945
This commit is contained in:
Viktor Szakats 2025-07-16 23:44:13 +02:00
parent 044de8e19b
commit 2c7902ec4a
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
2 changed files with 28 additions and 6 deletions

View file

@ -91,10 +91,26 @@ else()
mark_as_advanced(WOLFSSL_INCLUDE_DIR WOLFSSL_LIBRARY)
endif()
if(WOLFSSL_FOUND AND NOT WIN32)
find_library(MATH_LIBRARY NAMES "m")
if(MATH_LIBRARY)
list(APPEND WOLFSSL_LIBRARIES ${MATH_LIBRARY}) # for log and pow
if(WOLFSSL_FOUND)
if(APPLE)
find_library(SECURITY_FRAMEWORK NAMES "Security")
mark_as_advanced(SECURITY_FRAMEWORK)
if(NOT SECURITY_FRAMEWORK)
message(FATAL_ERROR "Security framework not found")
endif()
list(APPEND WOLFSSL_LIBRARIES "-framework Security")
find_library(COREFOUNDATION_FRAMEWORK NAMES "CoreFoundation")
mark_as_advanced(COREFOUNDATION_FRAMEWORK)
if(NOT COREFOUNDATION_FRAMEWORK)
message(FATAL_ERROR "CoreFoundation framework not found")
endif()
list(APPEND WOLFSSL_LIBRARIES "-framework CoreFoundation")
elseif(NOT WIN32)
find_library(MATH_LIBRARY NAMES "m")
if(MATH_LIBRARY)
list(APPEND WOLFSSL_LIBRARIES ${MATH_LIBRARY}) # for log and pow
endif()
mark_as_advanced(MATH_LIBRARY)
endif()
mark_as_advanced(MATH_LIBRARY)
endif()