cmake: speed up threads setup for Windows #12202
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Win32 threads are always available. We enabled them unconditionally
(with
ENABLE_THREADED_RESOLVER
). CMake built-in thread detectionlogic 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.
Closes #12202
The side effect is that on some targets
phtread
is no longer linkedautomatically to curl even when curl itself did not require or use it.
This was seen to happen with mingw-w64 on x86 and arm64 targets
(but not with x64), causing the
.map
file referencingpthread
lib, butwithout any actual use. If a curl dependency requires
pthread
and thedependency's CMake logic doesn't add it automatically, it needs to be
added manually to make it link in all cases, e.g. for BoringSSL with
mingw-w64, where it was already required for x64, but possibly worked
by accident for x86 and arm64.
Ref: curl/curl-for-win@74dd967#diff-98a81cf13297dad2803e548fe3ad9245cd8a732054f6ed89bff7360deaa3dff2R168-R170