[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 0/2] Stop using CMAKE_HAVE_THREADS_LIBRARY in the build system

Aris Adamantiadis <aris@xxxxxxxxxxxx> writes:

> Hi Raphael,
> I noticed your patch breaks compilation on macosx:

Oh, I didn't even know my patch series had been merged :-)

> 4e04ec8bf57bdb27ceb84867e04105b2820d3e1f is the first bad commit
> Author: Raphael Kubo da Costa <rakuco@xxxxxxxxxxx>
> Date:   Mon Feb 3 12:58:37 2014 +0200
>     threads: Be less strict when deciding whether to build
> libssh_threads.
> (according to git bisect)

I don't have access to an OS X system to test this myself, but here's my
guess: pthread(3)'s man page in OS X according to Apple's website says
no additional libraries or CFLAGS need to be specified for pthreads to
be used, so we'd fall into this case in FindThreads.cmake:

      # Check if pthread functions are in normal C library
      CHECK_SYMBOL_EXISTS(pthread_create pthread.h CMAKE_HAVE_LIBC_CREATE)
        set(CMAKE_THREAD_LIBS_INIT "")
        set(Threads_FOUND TRUE)

This means the previous check for CMAKE_HAVE_THREADS_LIBRARY worked and
libssh_threaded was built on OS X, but the new


will fail and libssh_threaded won't be built at all (which explains the
weird "-lssh_threads_static" in your linker output.

It seems to be an unfortunate consequence of the way Andreas and I
interpreted FindThread's documentation in
http://www.libssh.org/archive/libssh/2014-01/0000052.html: in OS X,
CMAKE_THREAD_LIBS_INIT is rightfully empty as "the thread library" is
"no library".

Does this patch fix things for you?

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index fa8c5c2..1891a00 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -288,6 +288,6 @@ if (WITH_STATIC_LIB)
+if (Threads_FOUND)
+endif (Threads_FOUND)

Re: [PATCH v2 0/2] Stop using CMAKE_HAVE_THREADS_LIBRARY in the build systemAris Adamantiadis <aris@xxxxxxxxxxxx>
Archive administrator: postmaster@lists.cynapses.org