summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2021-11-11 15:47:18 (GMT)
committerKitware Robot <kwrobot@kitware.com>2021-11-11 15:47:33 (GMT)
commit79354bf7a49fc7238463173cd45b097dc46cfc57 (patch)
tree92448998d421ed23b0b142322c265ba5197825b4 /Modules
parent06c6799e6fd51e7d721fe35a9bab9af9ea59e51b (diff)
parent68285bc8a91586ae47315679212eaef737af6cc0 (diff)
downloadCMake-79354bf7a49fc7238463173cd45b097dc46cfc57.zip
CMake-79354bf7a49fc7238463173cd45b097dc46cfc57.tar.gz
CMake-79354bf7a49fc7238463173cd45b097dc46cfc57.tar.bz2
Merge topic 'FindThreads-libc-pthread-flag'
68285bc8a9 FindThreads: Honor THREADS_PREFER_PTHREAD_FLAG when pthread is found in libc Acked-by: Kitware Robot <kwrobot@kitware.com> Tested-by: buildbot <buildbot@kitware.com> Merge-request: !6693
Diffstat (limited to 'Modules')
-rw-r--r--Modules/FindThreads.cmake19
1 files changed, 11 insertions, 8 deletions
diff --git a/Modules/FindThreads.cmake b/Modules/FindThreads.cmake
index e4d6cf3..4198374 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()