[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 2/2] threads: Use the right CMake check to decide whether to build the library.
[Thread Prev] | [Thread Next]
- Subject: [PATCH 2/2] threads: Use the right CMake check to decide whether to build the library.
- From: Raphael Kubo da Costa <rakuco@xxxxxxxxxxx>
- Reply-to: libssh@xxxxxxxxxx
- Date: Wed, 15 Jan 2014 22:56:31 +0200
- To: libssh@xxxxxxxxxx
CMAKE_HAVE_THREADS_LIBRARY may not be set in all cases where CMAKE_USE_PTHREADS_INIT is (for exampe, if one passes -DTHREADS_HAVE_PTHREAD_ARG=1 to CMake to tell it that -pthread is present and should be used), and we need the latter, not the former, to build our pthread.c. This also allows us to simplify the build system code in threads/, as we can assume that pthreads is present (this was already the case before, since if CMAKE_USE_PTHREADS_INIT was false add_library() would not build any source file at all). --- src/CMakeLists.txt | 4 ++-- src/threads/CMakeLists.txt | 24 +++--------------------- 2 files changed, 5 insertions(+), 23 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 83435d0..ced31c8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -288,6 +288,6 @@ if (WITH_STATIC_LIB) ) endif (WITH_STATIC_LIB) -if (CMAKE_HAVE_THREADS_LIBRARY) +if (CMAKE_USE_PTHREADS_INIT) add_subdirectory(threads) -endif (CMAKE_HAVE_THREADS_LIBRARY) +endif (CMAKE_USE_PTHREADS_INIT) diff --git a/src/threads/CMakeLists.txt b/src/threads/CMakeLists.txt index b95525e..50a3777 100644 --- a/src/threads/CMakeLists.txt +++ b/src/threads/CMakeLists.txt @@ -24,30 +24,12 @@ if (WITH_STATIC_LIB) endif (WITH_STATIC_LIB) set(LIBSSH_THREADS_LINK_LIBRARIES - ${LIBSSH_SHARED_LIBRARY} -) - -set(libssh_threads_SRCS -) - -# build and link pthread -if (CMAKE_USE_PTHREADS_INIT) - set(libssh_threads_SRCS - ${libssh_threads_SRCS} - pthread.c - ) - - set(LIBSSH_THREADS_LINK_LIBRARIES - ${LIBSSH_THREADS_LINK_LIBRARIES} - ${CMAKE_THREAD_LIBS_INIT} - ) -endif (CMAKE_USE_PTHREADS_INIT) - -set(LIBSSH_THREADS_LINK_LIBRARIES - ${LIBSSH_THREADS_LINK_LIBRARIES} + ${LIBSSH_SHARED_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} CACHE INTERNAL "libssh threads link libraries" ) +set(libssh_threads_SRCS pthread.c) + include_directories( ${LIBSSH_THREADS_PUBLIC_INCLUDE_DIRS} ${LIBSSH_THREADS_PRIVATE_INCLUDE_DIRS} -- 1.8.5.2
Re: [PATCH 2/2] threads: Use the right CMake check to decide whether to build the library. | Andreas Schneider <asn@xxxxxxxxxxxxxx> |
[PATCH 0/2] Stop using CMAKE_HAVE_THREADS_LIBRARY in the build system | Raphael Kubo da Costa <rakuco@xxxxxxxxxxx> |
[PATCH 1/2] ConfigureChecks: Stop checking for CMAKE_HAVE_THREADS_LIBRARY. | Raphael Kubo da Costa <rakuco@xxxxxxxxxxx> |