[CMake] FindThreads: GCC & pthreads bug?
Marcel Loose
loose at astron.nl
Wed Dec 12 10:18:51 EST 2012
Hi all,
I was browsing the FindThreads.cmake code and was wondering whether it
is doing the right thing when using GCC and pthreads.
The thing is that it first tries to locate the threads library and only
if it *cannot* find it, tries the command-line option "-pthread".
The proper way to tell GCC to compile with thread support is to use the
"-pthread" command-line option. Besides instructing the linke to link
against -lpthread, it will also set some preprocessor variables, like
_REENTRANT. Hence, simply linking against -lpthread is not sufficient.
So, IMHO, the test for the command-line option "-pthread" should be
tried first; and FindThreads should also set a variable containing the
preprocessor variables that should be set using add_definitions().
And a bit off topic: shouldn't FindThreads.cmake adhere to the
convention of setting a cache variable THREADS_LIBRARY and a non-cache
variable THREADS_LIBRARIES?
Best regards,
Marcel Loose.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: loose.vcf
Type: text/x-vcard
Size: 292 bytes
Desc: not available
URL: <http://www.cmake.org/pipermail/cmake/attachments/20121212/92a72f8f/attachment.vcf>
More information about the CMake
mailing list