summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-01-26 13:54:00 (GMT)
committerBrad King <brad.king@kitware.com>2022-01-26 13:54:00 (GMT)
commitfc153c7ef87280d12ab0da0ea17eeb67f5cc6dfa (patch)
treec588d6de64650499505b700a6cf008aec9bfb2b0
parentece5378536a0329a4d6e7e8fcd40904b7364ac34 (diff)
parent5efb6fb51602aa11d98a2baa1313ab9b857d2672 (diff)
downloadCMake-fc153c7ef87280d12ab0da0ea17eeb67f5cc6dfa.zip
CMake-fc153c7ef87280d12ab0da0ea17eeb67f5cc6dfa.tar.gz
CMake-fc153c7ef87280d12ab0da0ea17eeb67f5cc6dfa.tar.bz2
Merge branch 'FindThreads-libc-pthread-flag' into release-3.21
Merge-request: !6906
-rw-r--r--Modules/FindThreads.cmake19
1 files changed, 11 insertions, 8 deletions
diff --git a/Modules/FindThreads.cmake b/Modules/FindThreads.cmake
index c6a3451..ffd3352 100644
--- a/Modules/FindThreads.cmake
+++ b/Modules/FindThreads.cmake
@@ -164,18 +164,21 @@ if(CMAKE_HAVE_PTHREAD_H)
elseif(CMAKE_CXX_COMPILER_LOADED)
CHECK_CXX_SOURCE_COMPILES("${PTHREAD_C_CXX_TEST_SOURCE}" CMAKE_HAVE_LIBC_PTHREAD)
endif()
- if(CMAKE_HAVE_LIBC_PTHREAD)
+
+ # Check for -pthread first if enabled. This is the recommended
+ # way, but not backwards compatible as one must also pass -pthread
+ # as compiler flag then.
+ if(THREADS_PREFER_PTHREAD_FLAG)
+ _check_pthreads_flag()
+ endif()
+
+ if(Threads_FOUND)
+ # do nothing, we are done
+ elseif(CMAKE_HAVE_LIBC_PTHREAD)
set(CMAKE_THREAD_LIBS_INIT "")
set(CMAKE_HAVE_THREADS_LIBRARY 1)
set(Threads_FOUND TRUE)
else()
- # Check for -pthread first if enabled. This is the recommended
- # way, but not backwards compatible as one must also pass -pthread
- # as compiler flag then.
- if (THREADS_PREFER_PTHREAD_FLAG)
- _check_pthreads_flag()
- endif ()
-
if(CMAKE_SYSTEM MATCHES "GHS-MULTI")
_check_threads_lib(posix pthread_create CMAKE_HAVE_PTHREADS_CREATE)
endif()