FindThreads: Try pthreads with no special option first (#11333)
QNX has the phtread stuff in the standard library. The best way would IMHO be to check if a program that uses pthread_* can be successfully linked without specifying any linker option before trying out the different flags.
This commit is contained in:
parent
a668c9f059
commit
3dc6f2bfb3
|
@ -23,6 +23,7 @@
|
||||||
|
|
||||||
INCLUDE (CheckIncludeFiles)
|
INCLUDE (CheckIncludeFiles)
|
||||||
INCLUDE (CheckLibraryExists)
|
INCLUDE (CheckLibraryExists)
|
||||||
|
INCLUDE (CheckSymbolExists)
|
||||||
SET(Threads_FOUND FALSE)
|
SET(Threads_FOUND FALSE)
|
||||||
|
|
||||||
# Do we have sproc?
|
# Do we have sproc?
|
||||||
|
@ -44,7 +45,15 @@ ELSE()
|
||||||
#
|
#
|
||||||
SET(CMAKE_HAVE_THREADS_LIBRARY)
|
SET(CMAKE_HAVE_THREADS_LIBRARY)
|
||||||
IF(NOT THREADS_HAVE_PTHREAD_ARG)
|
IF(NOT THREADS_HAVE_PTHREAD_ARG)
|
||||||
|
# Check if pthread functions are in normal C library
|
||||||
|
CHECK_SYMBOL_EXISTS(pthread_create pthread.h CMAKE_HAVE_LIBC_CREATE)
|
||||||
|
IF(CMAKE_HAVE_LIBC_CREATE)
|
||||||
|
SET(CMAKE_THREAD_LIBS_INIT "")
|
||||||
|
SET(CMAKE_HAVE_THREADS_LIBRARY 1)
|
||||||
|
SET(Threads_FOUND TRUE)
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
|
IF(NOT CMAKE_HAVE_THREADS_LIBRARY)
|
||||||
# Do we have -lpthreads
|
# Do we have -lpthreads
|
||||||
CHECK_LIBRARY_EXISTS(pthreads pthread_create "" CMAKE_HAVE_PTHREADS_CREATE)
|
CHECK_LIBRARY_EXISTS(pthreads pthread_create "" CMAKE_HAVE_PTHREADS_CREATE)
|
||||||
IF(CMAKE_HAVE_PTHREADS_CREATE)
|
IF(CMAKE_HAVE_PTHREADS_CREATE)
|
||||||
|
@ -57,8 +66,8 @@ ELSE()
|
||||||
CHECK_LIBRARY_EXISTS(pthread pthread_create "" CMAKE_HAVE_PTHREAD_CREATE)
|
CHECK_LIBRARY_EXISTS(pthread pthread_create "" CMAKE_HAVE_PTHREAD_CREATE)
|
||||||
IF(CMAKE_HAVE_PTHREAD_CREATE)
|
IF(CMAKE_HAVE_PTHREAD_CREATE)
|
||||||
SET(CMAKE_THREAD_LIBS_INIT "-lpthread")
|
SET(CMAKE_THREAD_LIBS_INIT "-lpthread")
|
||||||
SET(Threads_FOUND TRUE)
|
|
||||||
SET(CMAKE_HAVE_THREADS_LIBRARY 1)
|
SET(CMAKE_HAVE_THREADS_LIBRARY 1)
|
||||||
|
SET(Threads_FOUND TRUE)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
IF(CMAKE_SYSTEM MATCHES "SunOS.*")
|
IF(CMAKE_SYSTEM MATCHES "SunOS.*")
|
||||||
|
@ -70,7 +79,7 @@ ELSE()
|
||||||
SET(Threads_FOUND TRUE)
|
SET(Threads_FOUND TRUE)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
ENDIF(CMAKE_SYSTEM MATCHES "SunOS.*")
|
ENDIF(CMAKE_SYSTEM MATCHES "SunOS.*")
|
||||||
|
ENDIF(NOT CMAKE_HAVE_THREADS_LIBRARY)
|
||||||
ENDIF(NOT THREADS_HAVE_PTHREAD_ARG)
|
ENDIF(NOT THREADS_HAVE_PTHREAD_ARG)
|
||||||
|
|
||||||
IF(NOT CMAKE_HAVE_THREADS_LIBRARY)
|
IF(NOT CMAKE_HAVE_THREADS_LIBRARY)
|
||||||
|
@ -111,7 +120,7 @@ ELSE()
|
||||||
ENDIF(CMAKE_HAVE_PTHREAD_H)
|
ENDIF(CMAKE_HAVE_PTHREAD_H)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
IF(CMAKE_THREAD_LIBS_INIT)
|
IF(CMAKE_THREAD_LIBS_INIT OR CMAKE_HAVE_LIBC_CREATE)
|
||||||
SET(CMAKE_USE_PTHREADS_INIT 1)
|
SET(CMAKE_USE_PTHREADS_INIT 1)
|
||||||
SET(Threads_FOUND TRUE)
|
SET(Threads_FOUND TRUE)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
Loading…
Reference in New Issue