[CMake] Updated FindThreads.cmake in tracker

Marcel Loose loose at astron.nl
Wed Sep 23 04:59:49 EDT 2009


On Tue, 2009-09-22 at 09:04 -0400, S Roderick wrote:
> On Sep 22, 2009, at 06:25 , Marcel Loose wrote:
> 
> > On Mon, 2009-09-21 at 23:25 -0400, Philip Lowman wrote:
> >> On Mon, Sep 21, 2009 at 6:07 AM, Marcel Loose <loose at astron.nl>  
> >> wrote:
> >>
> >>        On Sun, 2009-09-20 at 19:32 -0400, Philip Lowman wrote:
> >>> On Sun, Sep 20, 2009 at 3:02 PM, Hendrik Sattler
> >>>
> >>> I'm hesitant to rewrite anything that works, especially if
> >>        it works on
> >>> platforms I don't have access too. :)
> >>>
> >>> Include & library variables probably could be added if it
> >>        can be done
> >>> in a safe way with the compile checks already in place.
> >>>
> >>> Not sure on -pthread, we've never added it to our gcc
> >>        command lines
> >>> before.  Looking at the man page, it's only a compile flag
> >>        under
> >>> IA-64, RS-6000, PPC, and SPARC.  Would recommending people
> >>        add it to
> >>> their compiler flags and only rely on the output of
> >>> ${CMAKE_THREAD_LIBS_INIT} for linking be the right thing to
> >>        do?
> >>
> >>
> >>        Hmm, don't know if the documentation is correct.
> >>
> >>        I tested this on Linux x86_64 (gcc 4.3) and on an old i686
> >>        (gcc 3.2). On
> >>        both systems, when I diff the output of 'gcc -E -dM' and 'gcc
> >>        -E -dM
> >>        -pthread' I get '#define _REENTRANT 1'.
> >>
> >>        So, -pthread clearly defines an extra preprocessor variable.
> >>
> >> We've always defined _REENTRANT manually and specified -lpthread but
> >> looking into this further I'm guessing we're just getting lucky since
> >> we've never built on platforms where this doesn't work.
> >>
> >> http://stackoverflow.com/questions/875789/gcc-do-i-need-dreentrant-with-pthreads
> >>
> >> Also regarding the lack of a global -pthread in the docs, this post
> >> was kind of illuminating.
> >>
> >> http://lists.freebsd.org/pipermail/freebsd-threads/2003-September/001202.html
> >>
> >> So the gist of it is, if your only Unix compiler is gcc and if you  
> >> add
> >> "-pthread" to your CMAKE_C_FLAGS/CMAKE_CXX_FLAGS you really have no
> >> need for FindThreads at all, as far as I can tell.
> >>
> >>
> >> -- 
> >> Philip Lowman
> >
> > Well, yes, unless you're considering Mac OSX a Unix system as well,
> > which IMHO it is, nowadays. GCC gives an 'unsupported option' warning
> > when specifying '-pthread'. So clearly, '-pthread' is not supported on
> > Mac OSX.
> >
> > Marcel Loose
> 
> -pthread works fine for me with gcc 4.0.1 on Mac OS X 10.5.x (Leopard).
> Stephen
> 
> 
Hi Stephen,

Seems they solved this in Mac OSX 10.5. Tiger (10.4) does give the
warning I mentioned.

Regards,
Marcel Loose.




More information about the CMake mailing list