FindThreads: introduce THREADS_PREFER_PTHREAD_FLAG (#14767)

This commit is contained in:
Rolf Eike Beer 2014-10-06 21:43:45 +02:00
parent bcb0e3872b
commit b7e5c5a23a
1 changed files with 18 additions and 0 deletions

View File

@ -25,6 +25,17 @@
# :: # ::
# #
# CMAKE_THREAD_PREFER_PTHREAD # 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. # Copyright 2002-2009 Kitware, Inc.
@ -126,6 +137,13 @@ else()
set(Threads_FOUND TRUE) set(Threads_FOUND TRUE)
else() 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(pthreads pthread_create CMAKE_HAVE_PTHREADS_CREATE)
_check_threads_lib(pthread pthread_create CMAKE_HAVE_PTHREAD_CREATE) _check_threads_lib(pthread pthread_create CMAKE_HAVE_PTHREAD_CREATE)
if(CMAKE_SYSTEM_NAME MATCHES "SunOS") if(CMAKE_SYSTEM_NAME MATCHES "SunOS")