aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2015-09-07 07:46:11 +0200
committerAndreas Schneider <asn@cryptomilk.org>2015-09-07 07:46:11 +0200
commit5b586fdfecbe12f3f8e69099d809ca96c7cb978e (patch)
tree8ee49721e6209c1189fe717a299c9c0eecaab904
parent2f193b5cbb0c57160d3c590140bc04befccfbb32 (diff)
downloadlibssh-5b586fdfecbe12f3f8e69099d809ca96c7cb978e.tar.gz
libssh-5b586fdfecbe12f3f8e69099d809ca96c7cb978e.tar.xz
libssh-5b586fdfecbe12f3f8e69099d809ca96c7cb978e.zip
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>
-rw-r--r--CMakeLists.txt16
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/threads/CMakeLists.txt9
-rw-r--r--tests/CMakeLists.txt4
-rw-r--r--tests/unittests/CMakeLists.txt12
5 files changed, 32 insertions, 10 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 69d01969..445710a0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -84,8 +84,8 @@ add_subdirectory(include)
add_subdirectory(src)
# pkg-config file
+if (UNIX)
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(
FILES
${CMAKE_CURRENT_BINARY_DIR}/libssh.pc
@@ -96,6 +96,20 @@ install(
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
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})
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 4865d765..1012ddf0 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -300,6 +300,7 @@ if (WITH_STATIC_LIB)
)
endif (WITH_STATIC_LIB)
+message(STATUS "Threads_FOUND=${Threads_FOUND}")
if (Threads_FOUND)
add_subdirectory(threads)
endif (Threads_FOUND)
diff --git a/src/threads/CMakeLists.txt b/src/threads/CMakeLists.txt
index a32d601e..2ab4e1ba 100644
--- a/src/threads/CMakeLists.txt
+++ b/src/threads/CMakeLists.txt
@@ -27,8 +27,9 @@ set(LIBSSH_THREADS_LINK_LIBRARIES
${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
if (CMAKE_USE_PTHREADS_INIT)
@@ -41,6 +42,8 @@ if (CMAKE_USE_PTHREADS_INIT)
${LIBSSH_THREADS_LINK_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
)
+
+ message(STATUS "libssh_threads_SRCS=${libssh_threads_SRCS}")
endif (CMAKE_USE_PTHREADS_INIT)
set(LIBSSH_THREADS_LINK_LIBRARIES
@@ -54,6 +57,8 @@ include_directories(
)
if (libssh_threads_SRCS)
+ set(LIBSSH_THREADS ON CACHE "libssh threads lib" INTERNAL)
+
add_library(${LIBSSH_THREADS_SHARED_LIBRARY} SHARED ${libssh_threads_SRCS})
target_link_libraries(${LIBSSH_THREADS_SHARED_LIBRARY} ${LIBSSH_THREADS_LINK_LIBRARIES})
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 3bbb3309..d87c9c2f 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -22,12 +22,12 @@ set(TORTURE_LINK_LIBRARIES
${LIBSSH_STATIC_LIBRARY}
${LIBSSH_LINK_LIBRARIES})
-if (Threads_FOUND)
+if (LIBSSH_THREADS)
set(TORTURE_LINK_LIBRARIES
${TORTURE_LINK_LIBRARIES}
${LIBSSH_THREADS_STATIC_LIBRARY}
${LIBSSH_THREADS_LINK_LIBRARIES})
-endif ()
+endif (LIBSSH_THREADS)
# create test library
add_library(${TORTURE_LIBRARY} STATIC cmdline.c torture.c)
diff --git a/tests/unittests/CMakeLists.txt b/tests/unittests/CMakeLists.txt
index 1c9b6914..21825978 100644
--- a/tests/unittests/CMakeLists.txt
+++ b/tests/unittests/CMakeLists.txt
@@ -14,11 +14,13 @@ if (UNIX AND NOT WIN32)
# requires ssh-keygen
add_cmocka_test(torture_keyfiles torture_keyfiles.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
add_cmocka_test(torture_channel torture_channel.c ${TORTURE_LIBRARY})
- if (WITH_SERVER AND Threads_FOUND)
- add_cmocka_test(torture_server_x11 torture_server_x11.c ${TORTURE_LIBRARY})
- endif (WITH_SERVER AND Threads_FOUND)
+ # requires pthread
+ if (LIBSSH_THREADS)
+ 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)