summaryrefslogtreecommitdiff
path: root/Modules/FindThreads.cmake
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-08-08 12:41:57 -0400
committerBrad King <brad.king@kitware.com>2022-08-08 12:41:57 -0400
commit720396378890ee93158343ff3d681423bf0bdd4a (patch)
tree102781ea7e5f3beceb24016ea18b48f95f301bcb /Modules/FindThreads.cmake
parent4be24f031a4829db75b85062cc67125035d8831e (diff)
downloadcmake-720396378890ee93158343ff3d681423bf0bdd4a.tar.gz
FindThreads: Skip check for -pthread flag when targeting the MSVC ABI
Since commit 3257c34073 (FindThreads: avoid failing in AIX when using -D_XOPEN_SOURCE=500, 2022-04-30, v3.24.0-rc1~197^2) we no longer check for `pthreads.h` before checking for the `-pthread` flag. Compilers targeting the MSVC ABI do not have such a flag, so avoid performing the check unnecessarily. Fixes: #23829
Diffstat (limited to 'Modules/FindThreads.cmake')
-rw-r--r--Modules/FindThreads.cmake6
1 files changed, 5 insertions, 1 deletions
diff --git a/Modules/FindThreads.cmake b/Modules/FindThreads.cmake
index a2304c2eb1..a675fd6755 100644
--- a/Modules/FindThreads.cmake
+++ b/Modules/FindThreads.cmake
@@ -122,7 +122,11 @@ endmacro()
macro(_threads_check_flag_pthread)
if(NOT Threads_FOUND)
# If we did not find -lpthreads, -lpthread, or -lthread, look for -pthread
- if(NOT DEFINED THREADS_HAVE_PTHREAD_ARG)
+ # except on compilers known to not have it.
+ if(MSVC)
+ # Compilers targeting the MSVC ABI do not have a -pthread flag.
+ set(THREADS_HAVE_PTHREAD_ARG FALSE)
+ elseif(NOT DEFINED THREADS_HAVE_PTHREAD_ARG)
message(CHECK_START "Check if compiler accepts -pthread")
if(CMAKE_C_COMPILER_LOADED)
set(_threads_src ${CMAKE_CURRENT_LIST_DIR}/CheckForPthreads.c)