threads: Build a libssh threading library.
Этот коммит содержится в:
родитель
2cca490076
Коммит
fbe102bada
@ -128,8 +128,6 @@ endif (Z_LIBRARY)
|
||||
if (CMAKE_HAVE_THREADS_LIBRARY)
|
||||
if (CMAKE_HAVE_PTHREADS_CREATE OR CMAKE_HAVE_PTHREAD_CREATE)
|
||||
set(HAVE_PTHREAD 1)
|
||||
|
||||
set(LIBSSH_REQUIRED_LIBRARIES ${LIBSSH_REQUIRED_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
|
||||
endif (CMAKE_HAVE_PTHREADS_CREATE OR CMAKE_HAVE_PTHREAD_CREATE)
|
||||
endif (CMAKE_HAVE_THREADS_LIBRARY)
|
||||
|
||||
|
@ -22,10 +22,10 @@
|
||||
#ifndef THREADS_H_
|
||||
#define THREADS_H_
|
||||
|
||||
#include <libssh/libssh.h>
|
||||
#include <libssh/callbacks.h>
|
||||
|
||||
int ssh_threads_init(void);
|
||||
void ssh_threads_finalize(void);
|
||||
|
||||
LIBSSH_API int ssh_threads_init(void);
|
||||
LIBSSH_API void ssh_threads_finalize(void);
|
||||
|
||||
#endif /* THREADS_H_ */
|
||||
|
@ -202,3 +202,6 @@ if (WITH_STATIC_LIB)
|
||||
)
|
||||
endif (WITH_STATIC_LIB)
|
||||
|
||||
if (CMAKE_HAVE_THREADS_LIBRARY)
|
||||
add_subdirectory(threads)
|
||||
endif (CMAKE_HAVE_THREADS_LIBRARY)
|
||||
|
109
src/threads/CMakeLists.txt
Обычный файл
109
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)
|
4
src/threads/native.c
Обычный файл
4
src/threads/native.c
Обычный файл
@ -0,0 +1,4 @@
|
||||
#include "config.h"
|
||||
#include <libssh/callbacks.h>
|
||||
|
||||
struct ssh_threads_callbacks_struct ssh_pthread_callbacks;
|
@ -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 */
|
||||
|
@ -16,7 +16,13 @@ include_directories(
|
||||
|
||||
# create test library
|
||||
add_library(${TORTURE_LIBRARY} SHARED torture.c cmdline.c)
|
||||
target_link_libraries(${TORTURE_LIBRARY} ${CHECK_LIBRARIES} ${LIBSSH_STATIC_LIBRARY} ${LIBSSH_LINK_LIBRARIES} ${ARGP_LIBRARIES})
|
||||
target_link_libraries(${TORTURE_LIBRARY}
|
||||
${CHECK_LIBRARIES}
|
||||
${LIBSSH_STATIC_LIBRARY}
|
||||
${LIBSSH_THREADS_STATIC_LIBRARY}
|
||||
${LIBSSH_LINK_LIBRARIES}
|
||||
${ARGP_LIBRARIES}
|
||||
)
|
||||
|
||||
set(TEST_TARGET_LIBRARIES ${SUPPORT_LIBRARY} ${LIBSSH_LINK_LIBRARIES})
|
||||
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user