<div class="gmail_quote">On Mon, Sep 21, 2009 at 6:07 AM, Marcel Loose <span dir="ltr"><<a href="mailto:loose@astron.nl">loose@astron.nl</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><div></div><div class="h5">On Sun, 2009-09-20 at 19:32 -0400, Philip Lowman wrote:<br>
> On Sun, Sep 20, 2009 at 3:02 PM, Hendrik Sattler<br>
><br>
> I'm hesitant to rewrite anything that works, especially if it works on<br>
> platforms I don't have access too. :)<br>
><br>
> Include & library variables probably could be added if it can be done<br>
> in a safe way with the compile checks already in place.<br>
><br>
> Not sure on -pthread, we've never added it to our gcc command lines<br>
> before. Looking at the man page, it's only a compile flag under<br>
> IA-64, RS-6000, PPC, and SPARC. Would recommending people add it to<br>
> their compiler flags and only rely on the output of<br>
> ${CMAKE_THREAD_LIBS_INIT} for linking be the right thing to do?<br>
<br>
</div></div>Hmm, don't know if the documentation is correct.<br>
<br>
I tested this on Linux x86_64 (gcc 4.3) and on an old i686 (gcc 3.2). On<br>
both systems, when I diff the output of 'gcc -E -dM' and 'gcc -E -dM<br>
-pthread' I get '#define _REENTRANT 1'.<br>
<br>
So, -pthread clearly defines an extra preprocessor variable.<br></blockquote><div><br>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.<br>
<br><a href="http://stackoverflow.com/questions/875789/gcc-do-i-need-dreentrant-with-pthreads">http://stackoverflow.com/questions/875789/gcc-do-i-need-dreentrant-with-pthreads</a><br><br>Also regarding the lack of a global -pthread in the docs, this post was kind of illuminating.<br>
<br><a href="http://lists.freebsd.org/pipermail/freebsd-threads/2003-September/001202.html">http://lists.freebsd.org/pipermail/freebsd-threads/2003-September/001202.html</a><br><br>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.<br>
<br></div></div>-- <br>Philip Lowman<br>