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.

<<attachment: loose.vcf>>

--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to