]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
cmake: speed up threads setup for Windows
authorViktor Szakats <commit@vsz.me>
Thu, 26 Oct 2023 08:28:20 +0000 (08:28 +0000)
committerViktor Szakats <commit@vsz.me>
Fri, 27 Oct 2023 00:37:34 +0000 (00:37 +0000)
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

CMakeLists.txt

index 6f2cf36ffd330460d9e5e897109b5ce61fac81b1..22832a5bcc50578835308ff1d19928ecdba84f0f 100644 (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