2020-03-12 00:15:12 +08:00
|
|
|
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
2024-09-08 21:04:08 +02:00
|
|
|
index 2eba16d..a46cb3d 100644
|
2020-03-12 00:15:12 +08:00
|
|
|
--- a/CMakeLists.txt
|
|
|
|
+++ b/CMakeLists.txt
|
2024-09-08 21:04:08 +02:00
|
|
|
@@ -123,7 +123,17 @@ endif()
|
|
|
|
# We now potentially need to link all executables against PThreads, if available
|
|
|
|
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
|
|
|
|
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
|
|
|
|
-find_package(Threads)
|
|
|
|
+if(NOT LINK_WITH_PTHREAD)
|
|
|
|
+ set(CMAKE_DISABLE_FIND_PACKAGE_Threads ON)
|
|
|
|
+elseif(WIN32 AND NOT MINGW)
|
|
|
|
+ find_package(PThreads4W REQUIRED)
|
|
|
|
+ set(CMAKE_THREAD_LIBS_INIT PThreads4W::PThreads4W)
|
|
|
|
+ add_definitions(-DLINK_WITH_PTHREAD)
|
|
|
|
+else()
|
|
|
|
+ find_package(Threads REQUIRED)
|
|
|
|
+ set(CMAKE_THREAD_LIBS_INIT Threads::Threads)
|
|
|
|
+ add_definitions(-DLINK_WITH_PTHREAD)
|
2020-03-12 00:15:12 +08:00
|
|
|
+endif()
|
|
|
|
|
2024-09-08 21:04:08 +02:00
|
|
|
# If this is the root project add longer list of available CMAKE_BUILD_TYPE values
|
|
|
|
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
|
|
|
diff --git a/cmake/MbedTLSConfig.cmake.in b/cmake/MbedTLSConfig.cmake.in
|
|
|
|
index b65bbab..5919c37 100644
|
|
|
|
--- a/cmake/MbedTLSConfig.cmake.in
|
|
|
|
+++ b/cmake/MbedTLSConfig.cmake.in
|
|
|
|
@@ -1,3 +1,11 @@
|
|
|
|
@PACKAGE_INIT@
|
|
|
|
|
|
|
|
+if("@LINK_WITH_PTHREAD@")
|
|
|
|
+ include(CMakeFindDependencyMacro)
|
|
|
|
+ if(WIN32 AND NOT MINGW)
|
|
|
|
+ find_dependency(PThreads4W)
|
|
|
|
+ else()
|
|
|
|
+ find_dependency(Threads)
|
|
|
|
+ endif()
|
|
|
|
+endif()
|
|
|
|
include("${CMAKE_CURRENT_LIST_DIR}/MbedTLSTargets.cmake")
|
|
|
|
diff --git a/include/mbedtls/mbedtls_config.h b/include/mbedtls/mbedtls_config.h
|
|
|
|
index 3592141..174cabc 100644
|
|
|
|
--- a/include/mbedtls/mbedtls_config.h
|
|
|
|
+++ b/include/mbedtls/mbedtls_config.h
|
|
|
|
@@ -2091,6 +2091,10 @@
|
|
|
|
* Uncomment this to enable pthread mutexes.
|
2020-03-12 00:15:12 +08:00
|
|
|
*/
|
2024-09-08 21:04:08 +02:00
|
|
|
//#define MBEDTLS_THREADING_PTHREAD
|
|
|
|
+#ifdef LINK_WITH_PTHREAD
|
2020-03-12 00:15:12 +08:00
|
|
|
+#define MBEDTLS_THREADING_C
|
|
|
|
+#define MBEDTLS_THREADING_PTHREAD
|
|
|
|
+#endif
|
|
|
|
|
2024-09-08 21:04:08 +02:00
|
|
|
/**
|
|
|
|
* \def MBEDTLS_USE_PSA_CRYPTO
|