[libc++] Build thread_win32.cpp only if LIBCXX_HAS_PTHREAD_API is not set

This allows building libc++ against winpthreads from mingw-w64 to support
operating systems older than Windows 7. The remaining libc++ code already
supports `WIN32` with `LIBCXX_HAS_PTHREAD_API`.

Note that there is also the older "pthreads-win32". However, that support
library implements `pthread_t` as a struct, which violates the libc++
assumption that `pthread_t` is always a scalar and can be compared,
ordered, and set to zero.

Differential Revision: https://reviews.llvm.org/D96339

GitOrigin-RevId: 0f5020af7f347f029b5687f7a6d3b72174995d59
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 76227d3..cfb7eb1 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -77,8 +77,13 @@
   list(APPEND LIBCXX_SOURCES
     support/win32/locale_win32.cpp
     support/win32/support.cpp
-    support/win32/thread_win32.cpp
     )
+
+  if (NOT LIBCXX_HAS_PTHREAD_API)
+    list(APPEND LIBCXX_SOURCES
+      support/win32/thread_win32.cpp
+      )
+  endif()
 elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "SunOS")
   list(APPEND LIBCXX_SOURCES
     support/solaris/mbsnrtowcs.inc