mirror of
https://github.com/cemu-project/vcpkg.git
synced 2025-02-22 18:47:09 +01:00
[libssh] Enable mbedtls's threading support (#10154)
* Add "pthreads" feature to mbedtls. * Cleanup portfile. * Fix mbedtls pthreads support for Linux. * [mbedtls] Require the pthreads port only on Windows. * [mbedtls] Work around dependency issues about static linking.
This commit is contained in:
parent
c84dfe7ddd
commit
2c68b1229b
@ -1,5 +1,5 @@
|
|||||||
Source: libssh
|
Source: libssh
|
||||||
Version: 0.9.3
|
Version: 0.9.3-1
|
||||||
Homepage: https://www.libssh.org/
|
Homepage: https://www.libssh.org/
|
||||||
Description: libssh is a multiplatform C library implementing the SSHv2 protocol on client and server side
|
Description: libssh is a multiplatform C library implementing the SSHv2 protocol on client and server side
|
||||||
Default-Features: crypto
|
Default-Features: crypto
|
||||||
@ -10,7 +10,7 @@ Build-Depends: libssh[mbedtls]
|
|||||||
Description: Default crypto backend
|
Description: Default crypto backend
|
||||||
|
|
||||||
Feature: mbedtls
|
Feature: mbedtls
|
||||||
Build-Depends: mbedtls
|
Build-Depends: mbedtls[pthreads]
|
||||||
Description: Crypto support (mbedTLS)
|
Description: Crypto support (mbedTLS)
|
||||||
|
|
||||||
Feature: openssl
|
Feature: openssl
|
||||||
|
@ -1,4 +1,8 @@
|
|||||||
Source: mbedtls
|
Source: mbedtls
|
||||||
Version: 2.16.3
|
Version: 2.16.3-1
|
||||||
Homepage: https://github.com/ARMmbed/mbedtls
|
Homepage: https://github.com/ARMmbed/mbedtls
|
||||||
Description: An open source, portable, easy to use, readable and flexible SSL library
|
Description: An open source, portable, easy to use, readable and flexible SSL library
|
||||||
|
|
||||||
|
Feature: pthreads
|
||||||
|
Build-Depends: pthreads (windows)
|
||||||
|
Description: Multi-threading support
|
||||||
|
98
ports/mbedtls/enable-pthread.patch
Executable file
98
ports/mbedtls/enable-pthread.patch
Executable file
@ -0,0 +1,98 @@
|
|||||||
|
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||||
|
index 5f7d0d886..d65cfeb2b 100644
|
||||||
|
--- a/CMakeLists.txt
|
||||||
|
+++ b/CMakeLists.txt
|
||||||
|
@@ -7,6 +7,7 @@ endif()
|
||||||
|
|
||||||
|
option(USE_PKCS11_HELPER_LIBRARY "Build mbed TLS with the pkcs11-helper library." OFF)
|
||||||
|
option(ENABLE_ZLIB_SUPPORT "Build mbed TLS with zlib library." OFF)
|
||||||
|
+option(ENABLE_PTHREAD "Build mbed TLS with pthread" OFF)
|
||||||
|
|
||||||
|
option(ENABLE_PROGRAMS "Build mbed TLS programs." ON)
|
||||||
|
|
||||||
|
@@ -174,6 +175,7 @@ else()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include_directories(include/)
|
||||||
|
+include_directories(${CMAKE_CURRENT_BINARY_DIR}/include/)
|
||||||
|
|
||||||
|
if(ENABLE_ZLIB_SUPPORT)
|
||||||
|
find_package(ZLIB)
|
||||||
|
@@ -183,6 +185,17 @@ if(ENABLE_ZLIB_SUPPORT)
|
||||||
|
endif(ZLIB_FOUND)
|
||||||
|
endif(ENABLE_ZLIB_SUPPORT)
|
||||||
|
|
||||||
|
+if(ENABLE_PTHREAD)
|
||||||
|
+ if(WIN32)
|
||||||
|
+ find_package(pthreads_windows REQUIRED)
|
||||||
|
+ include_directories(${PThreads4W_INCLUDE_DIR})
|
||||||
|
+ else()
|
||||||
|
+ set(CMAKE_THREAD_PREFER_PTHREAD ON)
|
||||||
|
+ find_package(Threads REQUIRED)
|
||||||
|
+ endif()
|
||||||
|
+ set(LINK_WITH_PTHREAD ON)
|
||||||
|
+endif()
|
||||||
|
+
|
||||||
|
add_subdirectory(library)
|
||||||
|
add_subdirectory(include)
|
||||||
|
|
||||||
|
diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt
|
||||||
|
index c2f2bd4e6..e110cd50c 100644
|
||||||
|
--- a/include/CMakeLists.txt
|
||||||
|
+++ b/include/CMakeLists.txt
|
||||||
|
@@ -1,9 +1,13 @@
|
||||||
|
option(INSTALL_MBEDTLS_HEADERS "Install mbed TLS headers." ON)
|
||||||
|
|
||||||
|
+configure_file(mbedtls/config_threading.h.in mbedtls/config_threading.h)
|
||||||
|
+
|
||||||
|
if(INSTALL_MBEDTLS_HEADERS)
|
||||||
|
|
||||||
|
file(GLOB headers "mbedtls/*.h")
|
||||||
|
|
||||||
|
+ set(headers ${headers} ${CMAKE_CURRENT_BINARY_DIR}/mbedtls/config_threading.h)
|
||||||
|
+
|
||||||
|
install(FILES ${headers}
|
||||||
|
DESTINATION include/mbedtls
|
||||||
|
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
|
||||||
|
diff --git a/include/mbedtls/config.h b/include/mbedtls/config.h
|
||||||
|
index 5df962ef6..f205bf599 100644
|
||||||
|
--- a/include/mbedtls/config.h
|
||||||
|
+++ b/include/mbedtls/config.h
|
||||||
|
@@ -26,6 +26,8 @@
|
||||||
|
* This file is part of mbed TLS (https://tls.mbed.org)
|
||||||
|
*/
|
||||||
|
|
||||||
|
+#include "mbedtls/config_threading.h"
|
||||||
|
+
|
||||||
|
#ifndef MBEDTLS_CONFIG_H
|
||||||
|
#define MBEDTLS_CONFIG_H
|
||||||
|
|
||||||
|
diff --git a/include/mbedtls/config_threading.h.in b/include/mbedtls/config_threading.h.in
|
||||||
|
new file mode 100644
|
||||||
|
index 000000000..f6286ed9c
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/include/mbedtls/config_threading.h.in
|
||||||
|
@@ -0,0 +1,6 @@
|
||||||
|
+#cmakedefine ENABLE_PTHREAD
|
||||||
|
+
|
||||||
|
+#ifdef ENABLE_PTHREAD
|
||||||
|
+#define MBEDTLS_THREADING_C
|
||||||
|
+#define MBEDTLS_THREADING_PTHREAD
|
||||||
|
+#endif
|
||||||
|
diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt
|
||||||
|
index 9330cff9b..54a815ee7 100644
|
||||||
|
--- a/library/CMakeLists.txt
|
||||||
|
+++ b/library/CMakeLists.txt
|
||||||
|
@@ -128,7 +128,11 @@ if(ENABLE_ZLIB_SUPPORT)
|
||||||
|
endif(ENABLE_ZLIB_SUPPORT)
|
||||||
|
|
||||||
|
if(LINK_WITH_PTHREAD)
|
||||||
|
- set(libs ${libs} pthread)
|
||||||
|
+ if(WIN32)
|
||||||
|
+ set(libs ${libs} ${PThreads4W_LIBRARY})
|
||||||
|
+ else()
|
||||||
|
+ set(libs ${libs} pthread)
|
||||||
|
+ endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (NOT USE_STATIC_MBEDTLS_LIBRARY AND NOT USE_SHARED_MBEDTLS_LIBRARY)
|
@ -1,5 +1,3 @@
|
|||||||
include(vcpkg_common_functions)
|
|
||||||
|
|
||||||
set(VCPKG_LIBRARY_LINKAGE static)
|
set(VCPKG_LIBRARY_LINKAGE static)
|
||||||
|
|
||||||
vcpkg_from_github(
|
vcpkg_from_github(
|
||||||
@ -8,12 +6,21 @@ vcpkg_from_github(
|
|||||||
REF mbedtls-2.16.3
|
REF mbedtls-2.16.3
|
||||||
SHA512 3d798f7de9c33325585d5d7c8608cc16acdcf42c246d283b2fb8a29f5e419f2899342965ff297432ef2ab20c91eaee28d6ca53349f5a68b0a4fd29d6905fc64c
|
SHA512 3d798f7de9c33325585d5d7c8608cc16acdcf42c246d283b2fb8a29f5e419f2899342965ff297432ef2ab20c91eaee28d6ca53349f5a68b0a4fd29d6905fc64c
|
||||||
HEAD_REF master
|
HEAD_REF master
|
||||||
|
PATCHES
|
||||||
|
enable-pthread.patch
|
||||||
|
)
|
||||||
|
|
||||||
|
vcpkg_check_features(
|
||||||
|
OUT_FEATURE_OPTIONS FEATURE_OPTIONS
|
||||||
|
FEATURES
|
||||||
|
pthreads ENABLE_PTHREAD
|
||||||
)
|
)
|
||||||
|
|
||||||
vcpkg_configure_cmake(
|
vcpkg_configure_cmake(
|
||||||
SOURCE_PATH ${SOURCE_PATH}
|
SOURCE_PATH ${SOURCE_PATH}
|
||||||
PREFER_NINJA
|
PREFER_NINJA
|
||||||
OPTIONS
|
OPTIONS
|
||||||
|
${FEATURE_OPTIONS}
|
||||||
-DENABLE_TESTING=OFF
|
-DENABLE_TESTING=OFF
|
||||||
-DENABLE_PROGRAMS=OFF
|
-DENABLE_PROGRAMS=OFF
|
||||||
)
|
)
|
||||||
@ -24,4 +31,8 @@ file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
|
|||||||
|
|
||||||
file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/mbedtls RENAME copyright)
|
file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/mbedtls RENAME copyright)
|
||||||
|
|
||||||
|
if(WIN32 AND pthreads IN_LIST FEATURES)
|
||||||
|
file(INSTALL ${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake DESTINATION ${CURRENT_PACKAGES_DIR}/share/mbedtls)
|
||||||
|
endif()
|
||||||
|
|
||||||
vcpkg_copy_pdbs()
|
vcpkg_copy_pdbs()
|
||||||
|
29
ports/mbedtls/vcpkg-cmake-wrapper.cmake
Normal file
29
ports/mbedtls/vcpkg-cmake-wrapper.cmake
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
|
||||||
|
find_path(MBEDTLS_INCLUDE_DIR mbedtls/ssl.h)
|
||||||
|
|
||||||
|
find_library(MBEDTLS_CRYPTO_LIBRARY mbedcrypto)
|
||||||
|
find_package(pthreads_windows QUIET)
|
||||||
|
set(MBEDTLS_CRYPTO_LIBRARY ${MBEDTLS_CRYPTO_LIBRARY} ${PThreads4W_LIBRARY})
|
||||||
|
find_library(MBEDTLS_X509_LIBRARY mbedx509)
|
||||||
|
find_library(MBEDTLS_TLS_LIBRARY mbedtls)
|
||||||
|
set(MBEDTLS_LIBRARIES ${MBEDTLS_CRYPTO_LIBRARY} ${MBEDTLS_X509_LIBRARY} ${MBEDTLS_TLS_LIBRARY})
|
||||||
|
|
||||||
|
if (MBEDTLS_INCLUDE_DIR AND EXISTS "${MBEDTLS_INCLUDE_DIR}/mbedtls/version.h")
|
||||||
|
file(
|
||||||
|
STRINGS ${MBEDTLS_INCLUDE_DIR}/mbedtls/version.h _MBEDTLS_VERLINE
|
||||||
|
REGEX "^#define[ \t]+MBEDTLS_VERSION_STRING[\t ].*"
|
||||||
|
)
|
||||||
|
string(REGEX REPLACE ".*MBEDTLS_VERSION_STRING[\t ]+\"(.*)\"" "\\1" MBEDTLS_VERSION ${_MBEDTLS_VERLINE})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
find_package_handle_standard_args(
|
||||||
|
mbedTLS
|
||||||
|
REQUIRED_VARS
|
||||||
|
MBEDTLS_INCLUDE_DIR
|
||||||
|
MBEDTLS_CRYPTO_LIBRARY
|
||||||
|
MBEDTLS_X509_LIBRARY
|
||||||
|
MBEDTLS_TLS_LIBRARY
|
||||||
|
PThreads4W_FOUND
|
||||||
|
VERSION_VAR MBEDTLS_VERSION
|
||||||
|
)
|
Loading…
x
Reference in New Issue
Block a user