[Cmake-commits] CMake branch, next, updated. v2.8.5-1667-g6bdbb01

David Cole david.cole at kitware.com
Sat Aug 20 14:57:20 EDT 2011


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, next has been updated
       via  6bdbb01da1f9fca7cb0bbf317ed4edd46adadbb9 (commit)
       via  fd61be71401ef9e0a241562fc31539273084deff (commit)
      from  a1dfda2f78a8bb257ef6a7522bca8c1960fc2eba (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6bdbb01da1f9fca7cb0bbf317ed4edd46adadbb9
commit 6bdbb01da1f9fca7cb0bbf317ed4edd46adadbb9
Merge: a1dfda2 fd61be7
Author:     David Cole <david.cole at kitware.com>
AuthorDate: Sat Aug 20 14:57:16 2011 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Sat Aug 20 14:57:16 2011 -0400

    Merge topic 'fix-11333-use-correct-thread-flags' into next
    
    fd61be7 FindThreads: Try pthreads with no special option first (#11333)


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=fd61be71401ef9e0a241562fc31539273084deff
commit fd61be71401ef9e0a241562fc31539273084deff
Author:     Rolf Eike Beer <eike at sf-mail.de>
AuthorDate: Mon Apr 25 11:33:15 2011 -0400
Commit:     David Cole <david.cole at kitware.com>
CommitDate: Sat Aug 20 14:36:34 2011 -0400

    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.

diff --git a/Modules/FindThreads.cmake b/Modules/FindThreads.cmake
index a6c2df8..21614fb 100644
--- a/Modules/FindThreads.cmake
+++ b/Modules/FindThreads.cmake
@@ -23,6 +23,7 @@
 
 INCLUDE (CheckIncludeFiles)
 INCLUDE (CheckLibraryExists)
+INCLUDE (CheckSymbolExists)
 SET(Threads_FOUND FALSE)
 
 # Do we have sproc?
@@ -44,33 +45,41 @@ ELSE()
     #
     SET(CMAKE_HAVE_THREADS_LIBRARY)
     IF(NOT THREADS_HAVE_PTHREAD_ARG)
-
-      # Do we have -lpthreads
-      CHECK_LIBRARY_EXISTS(pthreads pthread_create "" CMAKE_HAVE_PTHREADS_CREATE)
-      IF(CMAKE_HAVE_PTHREADS_CREATE)
-        SET(CMAKE_THREAD_LIBS_INIT "-lpthreads")
+      # 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()
 
-      # Ok, how about -lpthread
-      CHECK_LIBRARY_EXISTS(pthread pthread_create "" CMAKE_HAVE_PTHREAD_CREATE)
-      IF(CMAKE_HAVE_PTHREAD_CREATE)
-        SET(CMAKE_THREAD_LIBS_INIT "-lpthread")
-        SET(Threads_FOUND TRUE)
-        SET(CMAKE_HAVE_THREADS_LIBRARY 1)
-      ENDIF()
+      IF(NOT CMAKE_HAVE_THREADS_LIBRARY)
+        # Do we have -lpthreads
+        CHECK_LIBRARY_EXISTS(pthreads pthread_create "" CMAKE_HAVE_PTHREADS_CREATE)
+        IF(CMAKE_HAVE_PTHREADS_CREATE)
+          SET(CMAKE_THREAD_LIBS_INIT "-lpthreads")
+          SET(CMAKE_HAVE_THREADS_LIBRARY 1)
+          SET(Threads_FOUND TRUE)
+        ENDIF()
 
-      IF(CMAKE_SYSTEM MATCHES "SunOS.*")
-        # On sun also check for -lthread
-        CHECK_LIBRARY_EXISTS(thread thr_create "" CMAKE_HAVE_THR_CREATE)
-        IF(CMAKE_HAVE_THR_CREATE)
-          SET(CMAKE_THREAD_LIBS_INIT "-lthread")
+        # Ok, how about -lpthread
+        CHECK_LIBRARY_EXISTS(pthread pthread_create "" CMAKE_HAVE_PTHREAD_CREATE)
+        IF(CMAKE_HAVE_PTHREAD_CREATE)
+          SET(CMAKE_THREAD_LIBS_INIT "-lpthread")
           SET(CMAKE_HAVE_THREADS_LIBRARY 1)
           SET(Threads_FOUND TRUE)
         ENDIF()
-      ENDIF(CMAKE_SYSTEM MATCHES "SunOS.*")
 
+        IF(CMAKE_SYSTEM MATCHES "SunOS.*")
+          # On sun also check for -lthread
+          CHECK_LIBRARY_EXISTS(thread thr_create "" CMAKE_HAVE_THR_CREATE)
+          IF(CMAKE_HAVE_THR_CREATE)
+            SET(CMAKE_THREAD_LIBS_INIT "-lthread")
+            SET(CMAKE_HAVE_THREADS_LIBRARY 1)
+            SET(Threads_FOUND TRUE)
+          ENDIF()
+        ENDIF(CMAKE_SYSTEM MATCHES "SunOS.*")
+      ENDIF(NOT CMAKE_HAVE_THREADS_LIBRARY)
     ENDIF(NOT THREADS_HAVE_PTHREAD_ARG)
 
     IF(NOT CMAKE_HAVE_THREADS_LIBRARY)
@@ -111,7 +120,7 @@ ELSE()
   ENDIF(CMAKE_HAVE_PTHREAD_H)
 ENDIF()
 
-IF(CMAKE_THREAD_LIBS_INIT)
+IF(CMAKE_THREAD_LIBS_INIT OR CMAKE_HAVE_LIBC_CREATE)
   SET(CMAKE_USE_PTHREADS_INIT 1)
   SET(Threads_FOUND TRUE)
 ENDIF()

-----------------------------------------------------------------------

Summary of changes:
 Modules/FindThreads.cmake |   47 ++++++++++++++++++++++++++------------------
 1 files changed, 28 insertions(+), 19 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list