mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-10 10:26:47 +09:00
cmake: Handle libssh threas library correctly
This should fix the build on Windows and would not install pkg files.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
(cherry picked from commit 5b586fdfec)
This commit is contained in:
@@ -84,8 +84,8 @@ add_subdirectory(include)
|
|||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
|
|
||||||
# pkg-config file
|
# pkg-config file
|
||||||
|
if (UNIX)
|
||||||
configure_file(libssh.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/libssh.pc)
|
configure_file(libssh.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/libssh.pc)
|
||||||
configure_file(libssh_threads.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/libssh_threads.pc)
|
|
||||||
install(
|
install(
|
||||||
FILES
|
FILES
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/libssh.pc
|
${CMAKE_CURRENT_BINARY_DIR}/libssh.pc
|
||||||
@@ -96,6 +96,20 @@ install(
|
|||||||
pkgconfig
|
pkgconfig
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (LIBSSH_THREADS)
|
||||||
|
configure_file(libssh_threads.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/libssh_threads.pc)
|
||||||
|
install(
|
||||||
|
FILES
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/libssh.pc
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/libssh_threads.pc
|
||||||
|
DESTINATION
|
||||||
|
${LIB_INSTALL_DIR}/pkgconfig
|
||||||
|
COMPONENT
|
||||||
|
pkgconfig
|
||||||
|
)
|
||||||
|
endif (LIBSSH_THREADS)
|
||||||
|
endif (UNIX)
|
||||||
|
|
||||||
# cmake config files
|
# cmake config files
|
||||||
set(LIBSSH_LIBRARY_NAME ${CMAKE_SHARED_LIBRARY_PREFIX}ssh${CMAKE_SHARED_LIBRARY_SUFFIX})
|
set(LIBSSH_LIBRARY_NAME ${CMAKE_SHARED_LIBRARY_PREFIX}ssh${CMAKE_SHARED_LIBRARY_SUFFIX})
|
||||||
set(LIBSSH_THREADS_LIBRARY_NAME ${CMAKE_SHARED_LIBRARY_PREFIX}ssh${CMAKE_SHARED_LIBRARY_SUFFIX})
|
set(LIBSSH_THREADS_LIBRARY_NAME ${CMAKE_SHARED_LIBRARY_PREFIX}ssh${CMAKE_SHARED_LIBRARY_SUFFIX})
|
||||||
|
|||||||
@@ -300,6 +300,7 @@ if (WITH_STATIC_LIB)
|
|||||||
)
|
)
|
||||||
endif (WITH_STATIC_LIB)
|
endif (WITH_STATIC_LIB)
|
||||||
|
|
||||||
|
message(STATUS "Threads_FOUND=${Threads_FOUND}")
|
||||||
if (Threads_FOUND)
|
if (Threads_FOUND)
|
||||||
add_subdirectory(threads)
|
add_subdirectory(threads)
|
||||||
endif (Threads_FOUND)
|
endif (Threads_FOUND)
|
||||||
|
|||||||
@@ -27,8 +27,9 @@ set(LIBSSH_THREADS_LINK_LIBRARIES
|
|||||||
${LIBSSH_SHARED_LIBRARY}
|
${LIBSSH_SHARED_LIBRARY}
|
||||||
)
|
)
|
||||||
|
|
||||||
set(libssh_threads_SRCS
|
message(STATUS "threads library: Threads_FOUND=${Threads_FOUND}")
|
||||||
)
|
|
||||||
|
set(libssh_threads_SRCS) # empty SRC
|
||||||
|
|
||||||
# build and link pthread
|
# build and link pthread
|
||||||
if (CMAKE_USE_PTHREADS_INIT)
|
if (CMAKE_USE_PTHREADS_INIT)
|
||||||
@@ -41,6 +42,8 @@ if (CMAKE_USE_PTHREADS_INIT)
|
|||||||
${LIBSSH_THREADS_LINK_LIBRARIES}
|
${LIBSSH_THREADS_LINK_LIBRARIES}
|
||||||
${CMAKE_THREAD_LIBS_INIT}
|
${CMAKE_THREAD_LIBS_INIT}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
message(STATUS "libssh_threads_SRCS=${libssh_threads_SRCS}")
|
||||||
endif (CMAKE_USE_PTHREADS_INIT)
|
endif (CMAKE_USE_PTHREADS_INIT)
|
||||||
|
|
||||||
set(LIBSSH_THREADS_LINK_LIBRARIES
|
set(LIBSSH_THREADS_LINK_LIBRARIES
|
||||||
@@ -54,6 +57,8 @@ include_directories(
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (libssh_threads_SRCS)
|
if (libssh_threads_SRCS)
|
||||||
|
set(LIBSSH_THREADS ON CACHE "libssh threads lib" INTERNAL)
|
||||||
|
|
||||||
add_library(${LIBSSH_THREADS_SHARED_LIBRARY} SHARED ${libssh_threads_SRCS})
|
add_library(${LIBSSH_THREADS_SHARED_LIBRARY} SHARED ${libssh_threads_SRCS})
|
||||||
|
|
||||||
target_link_libraries(${LIBSSH_THREADS_SHARED_LIBRARY} ${LIBSSH_THREADS_LINK_LIBRARIES})
|
target_link_libraries(${LIBSSH_THREADS_SHARED_LIBRARY} ${LIBSSH_THREADS_LINK_LIBRARIES})
|
||||||
|
|||||||
@@ -22,12 +22,12 @@ set(TORTURE_LINK_LIBRARIES
|
|||||||
${LIBSSH_STATIC_LIBRARY}
|
${LIBSSH_STATIC_LIBRARY}
|
||||||
${LIBSSH_LINK_LIBRARIES})
|
${LIBSSH_LINK_LIBRARIES})
|
||||||
|
|
||||||
if (Threads_FOUND)
|
if (LIBSSH_THREADS)
|
||||||
set(TORTURE_LINK_LIBRARIES
|
set(TORTURE_LINK_LIBRARIES
|
||||||
${TORTURE_LINK_LIBRARIES}
|
${TORTURE_LINK_LIBRARIES}
|
||||||
${LIBSSH_THREADS_STATIC_LIBRARY}
|
${LIBSSH_THREADS_STATIC_LIBRARY}
|
||||||
${LIBSSH_THREADS_LINK_LIBRARIES})
|
${LIBSSH_THREADS_LINK_LIBRARIES})
|
||||||
endif ()
|
endif (LIBSSH_THREADS)
|
||||||
|
|
||||||
# create test library
|
# create test library
|
||||||
add_library(${TORTURE_LIBRARY} STATIC cmdline.c torture.c)
|
add_library(${TORTURE_LIBRARY} STATIC cmdline.c torture.c)
|
||||||
|
|||||||
@@ -14,11 +14,13 @@ if (UNIX AND NOT WIN32)
|
|||||||
# requires ssh-keygen
|
# requires ssh-keygen
|
||||||
add_cmocka_test(torture_keyfiles torture_keyfiles.c ${TORTURE_LIBRARY})
|
add_cmocka_test(torture_keyfiles torture_keyfiles.c ${TORTURE_LIBRARY})
|
||||||
add_cmocka_test(torture_pki torture_pki.c ${TORTURE_LIBRARY})
|
add_cmocka_test(torture_pki torture_pki.c ${TORTURE_LIBRARY})
|
||||||
# requires pthread
|
|
||||||
add_cmocka_test(torture_rand torture_rand.c ${TORTURE_LIBRARY})
|
|
||||||
# requires /dev/null
|
# requires /dev/null
|
||||||
add_cmocka_test(torture_channel torture_channel.c ${TORTURE_LIBRARY})
|
add_cmocka_test(torture_channel torture_channel.c ${TORTURE_LIBRARY})
|
||||||
if (WITH_SERVER AND Threads_FOUND)
|
# requires pthread
|
||||||
add_cmocka_test(torture_server_x11 torture_server_x11.c ${TORTURE_LIBRARY})
|
if (LIBSSH_THREADS)
|
||||||
endif (WITH_SERVER AND Threads_FOUND)
|
add_cmocka_test(torture_rand torture_rand.c ${TORTURE_LIBRARY})
|
||||||
|
if (WITH_SERVER)
|
||||||
|
add_cmocka_test(torture_server_x11 torture_server_x11.c ${TORTURE_LIBRARY})
|
||||||
|
endif (WITH_SERVER)
|
||||||
|
endif (LIBSSH_THREADS)
|
||||||
endif (UNIX AND NOT WIN32)
|
endif (UNIX AND NOT WIN32)
|
||||||
|
|||||||
Reference in New Issue
Block a user