cmake: speed up threads setup for Windows

Win32 threads are always available. We enabled them unconditionally
(with `ENABLE_THREADED_RESOLVER`). CMake built-in thread detection
logic has this condition hard-coded for Windows as well (since at least
2007).

Instead of doing all the work of detecting pthread combinations on
Windows, then discarding those results, skip these efforts and assume
built-in thread support when building for Windows.

This saves 1-3 slow CMake configuration steps.

Reviewed-by: Daniel Stenberg
Closes #12202
This commit is contained in:
Viktor Szakats 2023-10-26 08:28:20 +00:00
parent c5d506e9bb
commit 191e695fe4
No known key found for this signature in database
GPG Key ID: B5ABD165E2AEF201

View File

@ -369,14 +369,14 @@ if(WIN32)
endif()
if(ENABLE_THREADED_RESOLVER)
find_package(Threads REQUIRED)
if(WIN32)
set(USE_THREADS_WIN32 ON)
else()
find_package(Threads REQUIRED)
set(USE_THREADS_POSIX ${CMAKE_USE_PTHREADS_INIT})
set(HAVE_PTHREAD_H ${CMAKE_USE_PTHREADS_INIT})
set(CURL_LIBS ${CURL_LIBS} ${CMAKE_THREAD_LIBS_INIT})
endif()
set(CURL_LIBS ${CURL_LIBS} ${CMAKE_THREAD_LIBS_INIT})
endif()
# Check for all needed libraries