CMake/Modules/FindThreads.cmake

71 lines
2.4 KiB
CMake
Raw Normal View History

2002-11-12 22:19:13 +03:00
# This module determines the thread library of the system.
# The following variables are set
2002-11-18 23:14:44 +03:00
# CMAKE_THREAD_LIBS_INIT - the thread library to link into an application (-lpthread )
# CMAKE_USE_SPROC_INIT - are we using sproc?
# CMAKE_USE_WIN32_THREADS_INIT - are we using WIN32 threads
# CMAKE_USE_PTHREADS_INIT - are we using pthreads
# CMAKE_HP_PTHREADS_INIT - are we using hp pthreads
2002-11-12 22:19:13 +03:00
INCLUDE (${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
INCLUDE (${CMAKE_ROOT}/Modules/CheckLibraryExists.cmake)
IF(CMAKE_SYSTEM MATCHES IRIX)
CHECK_INCLUDE_FILE("sys/prctl.h" CMAKE_HAVE_SPROC_H)
ENDIF(CMAKE_SYSTEM MATCHES IRIX)
CHECK_INCLUDE_FILE("pthread.h" CMAKE_HAVE_PTHREAD_H)
IF(CMAKE_HAVE_PTHREAD_H)
IF(NOT CMAKE_HAVE_SPROC_H)
CHECK_LIBRARY_EXISTS(pthreads pthread_create "" CMAKE_HAVE_PTHREADS_CREATE)
IF(CMAKE_HAVE_PTHREADS_CREATE)
2002-11-18 23:14:44 +03:00
SET(CMAKE_THREAD_LIBS_INIT "-lpthreads")
2002-11-12 22:19:13 +03:00
ENDIF(CMAKE_HAVE_PTHREADS_CREATE)
CHECK_LIBRARY_EXISTS(pthread pthread_create "" CMAKE_HAVE_PTHREAD_CREATE)
IF(CMAKE_HAVE_PTHREAD_CREATE)
2002-11-18 23:14:44 +03:00
SET(CMAKE_THREAD_LIBS_INIT "-lpthread")
2002-11-12 22:19:13 +03:00
ENDIF(CMAKE_HAVE_PTHREAD_CREATE)
IF(CMAKE_SYSTEM MATCHES "SunOS.*")
CHECK_LIBRARY_EXISTS(thread thr_create "" CMAKE_HAVE_THR_CREATE)
IF(CMAKE_HAVE_THR_CREATE)
2002-11-18 23:14:44 +03:00
SET(CMAKE_THREAD_LIBS_INIT "-lthread")
2002-11-12 22:19:13 +03:00
ENDIF(CMAKE_HAVE_THR_CREATE)
ENDIF(CMAKE_SYSTEM MATCHES "SunOS.*")
ENDIF(NOT CMAKE_HAVE_SPROC_H)
ENDIF(CMAKE_HAVE_PTHREAD_H)
IF(CMAKE_HAVE_SPROC_H)
2002-11-18 23:14:44 +03:00
SET(CMAKE_USE_SPROC_INIT 1)
2002-11-12 22:19:13 +03:00
ENDIF(CMAKE_HAVE_SPROC_H)
2002-11-18 23:14:44 +03:00
IF(CMAKE_THREAD_LIBS_INIT)
SET(CMAKE_USE_PTHREADS_INIT 1)
ENDIF(CMAKE_THREAD_LIBS_INIT)
2002-11-12 22:19:13 +03:00
IF(CMAKE_SYSTEM MATCHES "Windows")
2002-11-18 23:14:44 +03:00
SET(CMAKE_USE_WIN32_THREADS_INIT 1)
2002-11-12 22:19:13 +03:00
ENDIF(CMAKE_SYSTEM MATCHES "Windows")
2002-11-18 23:14:44 +03:00
IF(CMAKE_USE_PTHREADS_INIT)
2002-11-15 17:30:46 +03:00
IF(CMAKE_SYSTEM MATCHES "HP-UX-*")
2002-11-18 23:14:44 +03:00
SET(CMAKE_THREAD_LIBS_INIT "-lcma")
SET(CMAKE_USE_PTHREADS_INIT 1)
SET(CMAKE_HP_PTHREADS_INIT 1)
2002-11-15 17:30:46 +03:00
ENDIF(CMAKE_SYSTEM MATCHES "HP-UX-*")
2002-11-12 22:19:13 +03:00
2002-11-15 17:30:46 +03:00
IF(CMAKE_SYSTEM MATCHES "OSF1-V*")
2002-11-18 23:14:44 +03:00
SET(CMAKE_USE_PTHREADS_INIT 0)
SET(CMAKE_THREAD_LIBS_INIT )
2002-11-15 17:30:46 +03:00
ENDIF(CMAKE_SYSTEM MATCHES "OSF1-V*")
2002-11-12 22:19:13 +03:00
2002-11-15 17:30:46 +03:00
IF(CMAKE_SYSTEM MATCHES "FreeBSD*")
2002-11-18 23:14:44 +03:00
SET(CMAKE_USE_PTHREADS_INIT 0)
SET(CMAKE_THREAD_LIBS_INIT )
2002-11-15 17:30:46 +03:00
ENDIF(CMAKE_SYSTEM MATCHES "FreeBSD*")
2002-11-12 22:19:13 +03:00
2002-11-15 17:30:46 +03:00
IF(CMAKE_SYSTEM MATCHES "CYGWIN_NT*")
2002-11-18 23:14:44 +03:00
SET(CMAKE_USE_PTHREADS_INIT 1)
SET(CMAKE_THREAD_LIBS_INIT )
SET(CMAKE_USE_WIN32_THREADS_INIT 0)
2002-11-15 17:30:46 +03:00
ENDIF(CMAKE_SYSTEM MATCHES "CYGWIN_NT*")
2002-11-18 23:14:44 +03:00
ENDIF(CMAKE_USE_PTHREADS_INIT)
2002-11-12 22:19:13 +03:00