diff options
author | Andy Cedilnik <andy.cedilnik@kitware.com> | 2003-08-01 20:48:41 (GMT) |
---|---|---|
committer | Andy Cedilnik <andy.cedilnik@kitware.com> | 2003-08-01 20:48:41 (GMT) |
commit | ff5f0312deff4e67ad68e541f4d3744ab956c3ae (patch) | |
tree | aa227f202015ac0457da0460fad9edd5fd0f9c17 /Modules/FindThreads.cmake | |
parent | cb4e99f712ffd78ed1177421d8f934204297e5d7 (diff) | |
download | CMake-ff5f0312deff4e67ad68e541f4d3744ab956c3ae.zip CMake-ff5f0312deff4e67ad68e541f4d3744ab956c3ae.tar.gz CMake-ff5f0312deff4e67ad68e541f4d3744ab956c3ae.tar.bz2 |
ENH: Do better test for pthreads
Diffstat (limited to 'Modules/FindThreads.cmake')
-rw-r--r-- | Modules/FindThreads.cmake | 53 |
1 files changed, 39 insertions, 14 deletions
diff --git a/Modules/FindThreads.cmake b/Modules/FindThreads.cmake index d5cab19..f3050e8 100644 --- a/Modules/FindThreads.cmake +++ b/Modules/FindThreads.cmake @@ -16,20 +16,45 @@ 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) - SET(CMAKE_THREAD_LIBS_INIT "-lpthreads") - ENDIF(CMAKE_HAVE_PTHREADS_CREATE) - CHECK_LIBRARY_EXISTS(pthread pthread_create "" CMAKE_HAVE_PTHREAD_CREATE) - IF(CMAKE_HAVE_PTHREAD_CREATE) - SET(CMAKE_THREAD_LIBS_INIT "-lpthread") - 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) - SET(CMAKE_THREAD_LIBS_INIT "-lthread") - ENDIF(CMAKE_HAVE_THR_CREATE) - ENDIF(CMAKE_SYSTEM MATCHES "SunOS.*") + IF("THREADS_HAVE_PTHREAD_ARG" MATCHES "^THREADS_HAVE_PTHREAD_ARG") + MESSAGE(STATUS "Check if compiler accepts -pthread") + TRY_RUN(THREADS_PTHREAD_ARG THREADS_HAVE_PTHREAD_ARG + ${CMAKE_BINARY_DIR} + ${CMAKE_ROOT}/Modules/CheckForPthreads.c + CMAKE_FLAGS -DLINK_LIBRARIES:STRING=-pthread + OUTPUT_VARIABLE OUTPUT) + IF(THREADS_HAVE_PTHREAD_ARG) + IF(THREADS_PTHREAD_ARG MATCHES "^2$") + MESSAGE(STATUS "Check if compiler accepts -pthread - yes") + ELSE(THREADS_PTHREAD_ARG MATCHES "^2$") + MESSAGE(STATUS "Check if compiler accepts -pthread - no") + FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeError.log + "Determining if compiler accepts -pthread returned ${THREADS_PTHREAD_ARG} instead of 2. The compiler had the following output:\n${OUTPUT}\n\n") + ENDIF(THREADS_PTHREAD_ARG MATCHES "^2$") + ELSE(THREADS_HAVE_PTHREAD_ARG) + MESSAGE(STATUS "Check if compiler accepts -pthread - no") + FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeError.log + "Determining if compiler accepts -pthread failed with the following output:\n${OUTPUT}\n\n") + ENDIF(THREADS_HAVE_PTHREAD_ARG) + ENDIF("THREADS_HAVE_PTHREAD_ARG" MATCHES "^THREADS_HAVE_PTHREAD_ARG") + IF(THREADS_HAVE_PTHREAD_ARG) + SET(CMAKE_THREAD_LIBS_INIT "-pthread") + ELSE(THREADS_HAVE_PTHREAD_ARG) + CHECK_LIBRARY_EXISTS(pthreads pthread_create "" CMAKE_HAVE_PTHREADS_CREATE) + IF(CMAKE_HAVE_PTHREADS_CREATE) + SET(CMAKE_THREAD_LIBS_INIT "-lpthreads") + ENDIF(CMAKE_HAVE_PTHREADS_CREATE) + CHECK_LIBRARY_EXISTS(pthread pthread_create "" CMAKE_HAVE_PTHREAD_CREATE) + IF(CMAKE_HAVE_PTHREAD_CREATE) + SET(CMAKE_THREAD_LIBS_INIT "-lpthread") + 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) + SET(CMAKE_THREAD_LIBS_INIT "-lthread") + ENDIF(CMAKE_HAVE_THR_CREATE) + ENDIF(CMAKE_SYSTEM MATCHES "SunOS.*") + ENDIF(THREADS_HAVE_PTHREAD_ARG) ENDIF(NOT CMAKE_HAVE_SPROC_H) ENDIF(CMAKE_HAVE_PTHREAD_H) |