diff options
author | Brad King <brad.king@kitware.com> | 2022-01-27 16:04:00 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2022-01-27 16:04:06 (GMT) |
commit | 6a037fd9f428e50806f4bfcbbaa8e944fb54248b (patch) | |
tree | 9df3db39e00c4ee718ff4e4ab9ddafed5cf06864 /Modules | |
parent | 94189fc39759d5eb2d3c2ddaf9556ac4eb2abc64 (diff) | |
parent | 5efb6fb51602aa11d98a2baa1313ab9b857d2672 (diff) | |
download | CMake-6a037fd9f428e50806f4bfcbbaa8e944fb54248b.zip CMake-6a037fd9f428e50806f4bfcbbaa8e944fb54248b.tar.gz CMake-6a037fd9f428e50806f4bfcbbaa8e944fb54248b.tar.bz2 |
Merge topic 'FindThreads-libc-pthread-flag' into release-3.22
5efb6fb516 FindThreads: Honor THREADS_PREFER_PTHREAD_FLAG when pthread is found in libc
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !6906
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/FindThreads.cmake | 19 |
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() |