aboutsummaryrefslogtreecommitdiff
path: root/src/threads
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cynapses.org>2010-09-06 14:54:16 +0200
committerAndreas Schneider <asn@cynapses.org>2010-09-06 15:17:03 +0200
commitfbe102bada583f308450c27e256053b51643a532 (patch)
treea855a670d43df50647b5f90a89e15c093f26793f /src/threads
parent2cca490076841b431d7a83d020d90e1ad00bbca5 (diff)
downloadlibssh-fbe102bada583f308450c27e256053b51643a532.tar.gz
libssh-fbe102bada583f308450c27e256053b51643a532.tar.xz
libssh-fbe102bada583f308450c27e256053b51643a532.zip
threads: Build a libssh threading library.
Diffstat (limited to 'src/threads')
-rw-r--r--src/threads/CMakeLists.txt109
-rw-r--r--src/threads/native.c4
-rw-r--r--src/threads/pthread.c3
3 files changed, 116 insertions, 0 deletions
diff --git a/src/threads/CMakeLists.txt b/src/threads/CMakeLists.txt
new file mode 100644
index 00000000..1cf3d7b1
--- /dev/null
+++ b/src/threads/CMakeLists.txt
@@ -0,0 +1,109 @@
+project(libssh-threads C)
+
+set(LIBSSH_THREADS_PUBLIC_INCLUDE_DIRS
+ ${CMAKE_SOURCE_DIR}/include
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_SOURCE_DIR}
+ CACHE INTERNAL "libssh public include directories"
+)
+
+set(LIBSSH_PRIVATE_INCLUDE_DIRS
+ ${CMAKE_BINARY_DIR}
+)
+
+set(LIBSSH_THREADS_SHARED_LIBRARY
+ ssh_threads_shared
+ CACHE INTERNAL "libssh threads shared library"
+)
+
+if (WITH_STATIC_LIB)
+ set(LIBSSH_THREADS_STATIC_LIBRARY
+ ssh_threads_static
+ CACHE INTERNAL "libssh threads static library"
+ )
+endif (WITH_STATIC_LIB)
+
+set(LIBSSH_THREADS_LINK_LIBRARIES
+ ${LIBSSH_LINK_LIBRARIES}
+)
+
+set(LIBSSH_THREADS_LINK_LIBRARIES
+ ${LIBSSH_THREADS_LINK_LIBRARIES}
+ CACHE INTERNAL "libssh threads link libraries"
+)
+
+set(libssh_threads_SRCS
+ native.c
+)
+
+# build and link pthread
+if (CMAKE_HAVE_PTHREADS_CREATE OR CMAKE_HAVE_PTHREAD_CREATE)
+ set(libssh_threads_SRCS
+ ${libssh_threads_SRCS}
+ pthread.c
+ )
+
+ set(LIBSSH_THREADS_LINK_LIBRARIES
+ ${LIBSSH_THREADS_LINK_LIBRARIES}
+ ${CMAKE_THREAD_LIBS_INIT}
+ )
+endif (CMAKE_HAVE_PTHREADS_CREATE OR CMAKE_HAVE_PTHREAD_CREATE)
+
+include_directories(
+ ${LIBSSH_THREADS_PUBLIC_INCLUDE_DIRS}
+ ${LIBSSH_THREADS_PRIVATE_INCLUDE_DIRS}
+)
+
+add_library(${LIBSSH_THREADS_SHARED_LIBRARY} SHARED ${libssh_threads_SRCS})
+
+target_link_libraries(${LIBSSH_THREADS_SHARED_LIBRARY} ${LIBSSH_THREADS_LINK_LIBRARIES})
+
+set_target_properties(
+ ${LIBSSH_THREADS_SHARED_LIBRARY}
+ PROPERTIES
+ VERSION
+ ${LIBRARY_VERSION}
+ SOVERSION
+ ${LIBRARY_SOVERSION}
+ OUTPUT_NAME
+ ssh_threads
+ DEFINE_SYMBOL
+ LIBSSH_EXPORTS
+)
+
+if (WITH_VISIBILITY_HIDDEN)
+ set_target_properties(${LIBSSH_THREADS_SHARED_LIBRARY} PROPERTIES COMPILE_FLAGS "-fvisibility=hidden")
+endif (WITH_VISIBILITY_HIDDEN)
+
+install(
+ TARGETS
+ ${LIBSSH_THREADS_SHARED_LIBRARY}
+ RUNTIME DESTINATION ${BIN_INSTALL_DIR}
+ LIBRARY DESTINATION ${LIB_INSTALL_DIR}
+ ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
+ COMPONENT libraries
+)
+
+if (WITH_STATIC_LIB)
+ add_library(${LIBSSH_THREADS_STATIC_LIBRARY} STATIC ${libssh_threads_SRCS})
+
+ set_target_properties(
+ ${LIBSSH_THREADS_STATIC_LIBRARY}
+ PROPERTIES
+ VERSION
+ ${LIBRARY_VERSION}
+ SOVERSION
+ ${LIBRARY_SOVERSION}
+ COMPILE_FLAGS
+ "-DLIBSSH_STATIC"
+ )
+
+ install(
+ TARGETS
+ ${LIBSSH_THREADS_STATIC_LIBRARY}
+ DESTINATION
+ ${LIB_INSTALL_DIR}
+ COMPONENT
+ libraries
+ )
+endif (WITH_STATIC_LIB)
diff --git a/src/threads/native.c b/src/threads/native.c
new file mode 100644
index 00000000..c65c18e4
--- /dev/null
+++ b/src/threads/native.c
@@ -0,0 +1,4 @@
+#include "config.h"
+#include <libssh/callbacks.h>
+
+struct ssh_threads_callbacks_struct ssh_pthread_callbacks;
diff --git a/src/threads/pthread.c b/src/threads/pthread.c
index 2f62ad3c..35589cc7 100644
--- a/src/threads/pthread.c
+++ b/src/threads/pthread.c
@@ -20,10 +20,12 @@
*/
#include "config.h"
+#include <libssh/callbacks.h>
#ifdef HAVE_PTHREAD
#include <errno.h>
+#include <stdlib.h>
#include <pthread.h>
/** @brief Defines the needed callbacks for pthread. Use this if your
@@ -81,4 +83,5 @@ static struct ssh_threads_callbacks_struct name= \
}
SSH_THREADS_PTHREAD(ssh_pthread_user_callbacks);
+
#endif /* HAVE_PTHREAD */