diff options
author | Brad King <brad.king@kitware.com> | 2021-11-11 15:47:18 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2021-11-11 15:47:33 (GMT) |
commit | 79354bf7a49fc7238463173cd45b097dc46cfc57 (patch) | |
tree | 92448998d421ed23b0b142322c265ba5197825b4 /Modules | |
parent | 06c6799e6fd51e7d721fe35a9bab9af9ea59e51b (diff) | |
parent | 68285bc8a91586ae47315679212eaef737af6cc0 (diff) | |
download | CMake-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.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() |