diff options
author | Rolf Eike Beer <eike@sf-mail.de> | 2014-10-06 19:43:45 (GMT) |
---|---|---|
committer | Rolf Eike Beer <eike@sf-mail.de> | 2014-10-08 15:57:34 (GMT) |
commit | b7e5c5a23ae8d429186873dd2095e2180f62f522 (patch) | |
tree | df6b23e9670cf488b4bea8eb2685a5059e6b63f8 /Modules/FindThreads.cmake | |
parent | bcb0e3872b50bbbd669285fe9b6156bac42a2690 (diff) | |
download | CMake-b7e5c5a23ae8d429186873dd2095e2180f62f522.zip CMake-b7e5c5a23ae8d429186873dd2095e2180f62f522.tar.gz CMake-b7e5c5a23ae8d429186873dd2095e2180f62f522.tar.bz2 |
FindThreads: introduce THREADS_PREFER_PTHREAD_FLAG (#14767)
Diffstat (limited to 'Modules/FindThreads.cmake')
-rw-r--r-- | Modules/FindThreads.cmake | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Modules/FindThreads.cmake b/Modules/FindThreads.cmake index 108b56f..a0bc4d1 100644 --- a/Modules/FindThreads.cmake +++ b/Modules/FindThreads.cmake @@ -25,6 +25,17 @@ # :: # # CMAKE_THREAD_PREFER_PTHREAD +# +# If the use of the -pthread compiler and linker flag is prefered then the +# caller can set +# +# :: +# +# THREADS_PREFER_PTHREAD_FLAG +# +# Please note that the compiler flag can only be used with the imported +# target. Use of both the imported target as well as this switch is highly +# recommended for new code. #============================================================================= # Copyright 2002-2009 Kitware, Inc. @@ -126,6 +137,13 @@ else() 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 () + _check_threads_lib(pthreads pthread_create CMAKE_HAVE_PTHREADS_CREATE) _check_threads_lib(pthread pthread_create CMAKE_HAVE_PTHREAD_CREATE) if(CMAKE_SYSTEM_NAME MATCHES "SunOS") |