summaryrefslogtreecommitdiff
path: root/Modules/FindThreads.cmake
diff options
context:
space:
mode:
authorRolf Eike Beer <eike@sf-mail.de>2014-10-06 21:43:45 +0200
committerRolf Eike Beer <eike@sf-mail.de>2014-10-08 17:57:34 +0200
commitb7e5c5a23ae8d429186873dd2095e2180f62f522 (patch)
treedf6b23e9670cf488b4bea8eb2685a5059e6b63f8 /Modules/FindThreads.cmake
parentbcb0e3872b50bbbd669285fe9b6156bac42a2690 (diff)
downloadcmake-b7e5c5a23ae8d429186873dd2095e2180f62f522.tar.gz
FindThreads: introduce THREADS_PREFER_PTHREAD_FLAG (#14767)
Diffstat (limited to 'Modules/FindThreads.cmake')
-rw-r--r--Modules/FindThreads.cmake18
1 files changed, 18 insertions, 0 deletions
diff --git a/Modules/FindThreads.cmake b/Modules/FindThreads.cmake
index 108b56f816..a0bc4d133e 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")