summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2019-11-06 09:03:11 +0100
committerAndreas Schneider <asn@cryptomilk.org>2019-11-07 14:01:00 +0100
commit82c57c1f3656a1d501488174c14a03de5425cbbb (patch)
treef4fdf0cb918c08c28defca8b0c9b4a31f75aead4
parentc2c354539112eb89862ec4472af3ea5aeafa2824 (diff)
downloadlibssh-82c57c1f3656a1d501488174c14a03de5425cbbb.tar.gz
libssh-82c57c1f3656a1d501488174c14a03de5425cbbb.tar.xz
libssh-82c57c1f3656a1d501488174c14a03de5425cbbb.zip
cmake: Create ssh library directly as libssh
Signed-off-by: Andreas Schneider <asn@cryptomilk.org> Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
-rw-r--r--examples/CMakeLists.txt32
-rwxr-xr-xobj/build_make.sh200
-rw-r--r--src/CMakeLists.txt30
-rw-r--r--tests/CMakeLists.txt2
-rw-r--r--tests/benchmarks/CMakeLists.txt10
-rw-r--r--tests/server/test_server/CMakeLists.txt2
6 files changed, 32 insertions, 244 deletions
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index ae93d061..065200b5 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -18,72 +18,72 @@ endif()
if (UNIX AND NOT WIN32)
add_executable(libssh_scp libssh_scp.c ${examples_SRCS})
target_compile_options(libssh_scp PRIVATE ${DEFAULT_C_COMPILE_FLAGS})
- target_link_libraries(libssh_scp ${LIBSSH_SHARED_LIBRARY})
+ target_link_libraries(libssh_scp ssh::ssh)
add_executable(scp_download scp_download.c ${examples_SRCS})
target_compile_options(scp_download PRIVATE ${DEFAULT_C_COMPILE_FLAGS})
- target_link_libraries(scp_download ${LIBSSH_SHARED_LIBRARY})
+ target_link_libraries(scp_download ssh::ssh)
add_executable(sshnetcat sshnetcat.c ${examples_SRCS})
target_compile_options(sshnetcat PRIVATE ${DEFAULT_C_COMPILE_FLAGS})
- target_link_libraries(sshnetcat ${LIBSSH_SHARED_LIBRARY})
+ target_link_libraries(sshnetcat ssh::ssh)
if (WITH_SFTP)
add_executable(samplesftp samplesftp.c ${examples_SRCS})
target_compile_options(samplesftp PRIVATE ${DEFAULT_C_COMPILE_FLAGS})
- target_link_libraries(samplesftp ${LIBSSH_SHARED_LIBRARY})
+ target_link_libraries(samplesftp ssh::ssh)
endif (WITH_SFTP)
add_executable(ssh-client ssh_client.c ${examples_SRCS})
target_compile_options(ssh-client PRIVATE ${DEFAULT_C_COMPILE_FLAGS})
- target_link_libraries(ssh-client ${LIBSSH_SHARED_LIBRARY})
+ target_link_libraries(ssh-client ssh::ssh)
if (WITH_SERVER AND (ARGP_LIBRARY OR HAVE_ARGP_H))
if (HAVE_LIBUTIL)
add_executable(ssh_server_fork ssh_server_fork.c)
target_compile_options(ssh_server_fork PRIVATE ${DEFAULT_C_COMPILE_FLAGS})
- target_link_libraries(ssh_server_fork ${LIBSSH_SHARED_LIBRARY} ${ARGP_LIBRARY} util)
+ target_link_libraries(ssh_server_fork ssh::ssh ${ARGP_LIBRARY} util)
endif (HAVE_LIBUTIL)
if (WITH_GSSAPI AND GSSAPI_FOUND)
add_executable(samplesshd-cb samplesshd-cb.c)
target_compile_options(samplesshd-cb PRIVATE ${DEFAULT_C_COMPILE_FLAGS})
- target_link_libraries(samplesshd-cb ${LIBSSH_SHARED_LIBRARY} ${ARGP_LIBRARY})
+ target_link_libraries(samplesshd-cb ssh::ssh ${ARGP_LIBRARY})
add_executable(proxy proxy.c)
target_compile_options(proxy PRIVATE ${DEFAULT_C_COMPILE_FLAGS})
- target_link_libraries(proxy ${LIBSSH_SHARED_LIBRARY} ${ARGP_LIBRARY})
+ target_link_libraries(proxy ssh::ssh ${ARGP_LIBRARY})
add_executable(sshd_direct-tcpip sshd_direct-tcpip.c)
target_compile_options(sshd_direct-tcpip PRIVATE ${DEFAULT_C_COMPILE_FLAGS})
- target_link_libraries(sshd_direct-tcpip ${LIBSSH_SHARED_LIBRARY} ${ARGP_LIBRARY})
+ target_link_libraries(sshd_direct-tcpip ssh::ssh ${ARGP_LIBRARY})
endif (WITH_GSSAPI AND GSSAPI_FOUND)
add_executable(samplesshd-kbdint samplesshd-kbdint.c)
target_compile_options(samplesshd-kbdint PRIVATE ${DEFAULT_C_COMPILE_FLAGS})
- target_link_libraries(samplesshd-kbdint ${LIBSSH_SHARED_LIBRARY} ${ARGP_LIBRARY})
+ target_link_libraries(samplesshd-kbdint ssh::ssh ${ARGP_LIBRARY})
add_executable(keygen2 keygen2.c ${examples_SRCS})
target_compile_options(keygen2 PRIVATE ${DEFAULT_C_COMPILE_FLAGS})
- target_link_libraries(keygen2 ${LIBSSH_SHARED_LIBRARY})
+ target_link_libraries(keygen2 ssh::ssh)
endif()
endif (UNIX AND NOT WIN32)
add_executable(exec exec.c ${examples_SRCS})
target_compile_options(exec PRIVATE ${DEFAULT_C_COMPILE_FLAGS})
-target_link_libraries(exec ${LIBSSH_SHARED_LIBRARY})
+target_link_libraries(exec ssh::ssh)
add_executable(senddata senddata.c ${examples_SRCS})
target_compile_options(senddata PRIVATE ${DEFAULT_C_COMPILE_FLAGS})
-target_link_libraries(senddata ${LIBSSH_SHARED_LIBRARY})
+target_link_libraries(senddata ssh::ssh)
add_executable(keygen keygen.c)
target_compile_options(keygen PRIVATE ${DEFAULT_C_COMPILE_FLAGS})
-target_link_libraries(keygen ${LIBSSH_SHARED_LIBRARY})
+target_link_libraries(keygen ssh::ssh)
add_executable(libsshpp libsshpp.cpp)
-target_link_libraries(libsshpp ${LIBSSH_SHARED_LIBRARY})
+target_link_libraries(libsshpp ssh::ssh)
add_executable(libsshpp_noexcept libsshpp_noexcept.cpp)
-target_link_libraries(libsshpp_noexcept ${LIBSSH_SHARED_LIBRARY})
+target_link_libraries(libsshpp_noexcept ssh::ssh)
diff --git a/obj/build_make.sh b/obj/build_make.sh
deleted file mode 100755
index 7c559141..00000000
--- a/obj/build_make.sh
+++ /dev/null
@@ -1,200 +0,0 @@
-#!/bin/bash
-#
-# Last Change: 2008-06-18 14:13:46
-#
-# Script to build libssh on UNIX.
-#
-# Copyright (c) 2006-2007 Andreas Schneider <asn@cryptomilk.org>
-#
-
-SOURCE_DIR=".."
-
-LANG=C
-export LANG
-
-SCRIPT="$0"
-COUNT=0
-while [ -L "${SCRIPT}" ]
-do
- SCRIPT=$(readlink ${SCRIPT})
- COUNT=$(expr ${COUNT} + 1)
- if [ ${COUNT} -gt 100 ]; then
- echo "Too many symbolic links"
- exit 1
- fi
-done
-BUILDDIR=$(dirname ${SCRIPT})
-
-cleanup_and_exit () {
- if test "$1" = 0 -o -z "$1" ; then
- exit 0
- else
- exit $1
- fi
-}
-
-function configure() {
- if [ -n "${CMAKEDIR}" ]; then
- ${CMAKEDIR}/bin/cmake "$@" ${SOURCE_DIR} || cleanup_and_exit $?
- else
- cmake "$@" ${SOURCE_DIR} || cleanup_and_exit $?
- fi
-}
-
-function compile() {
- if [ -f /proc/cpuinfo ]; then
- CPUCOUNT=$(grep -c processor /proc/cpuinfo)
- elif test `uname` = "SunOS" ; then
- CPUCOUNT=$(psrinfo -p)
- else
- CPUCOUNT="1"
- fi
-
- if [ "${CPUCOUNT}" -gt "1" ]; then
- ${MAKE} -j${CPUCOUNT} $1 || cleanup_and_exit $?
- else
- ${MAKE} $1 || exit $?
- fi
-}
-
-function clean_build_dir() {
- find ! -path "*.svn*" ! -name "*.bat" ! -name "*.sh" ! -name "." -print0 | xargs -0 rm -rf
-}
-
-function usage () {
-echo "Usage: `basename $0` [--prefix /install_prefix|--build [debug|final]|--clean|--verbose|--libsuffix (32|64)|--help|--clang|--cmakedir /directory|--make
-(gmake|make)|--ccompiler(gcc|cc)|--withstaticlib|--unittesting|--clientunittesting|--withserver|--withoutsymbolversioning]"
- cleanup_and_exit
-}
-
-cd ${BUILDDIR}
-
-# the default CMake options:
-OPTIONS="--graphviz=${BUILDDIR}/libssh.dot"
-
-# the default 'make' utility:
-MAKE="make"
-
-while test -n "$1"; do
- PARAM="$1"
- ARG="$2"
- shift
- case ${PARAM} in
- *-*=*)
- ARG=${PARAM#*=}
- PARAM=${PARAM%%=*}
- set -- "----noarg=${PARAM}" "$@"
- esac
- case ${PARAM} in
- *-help|-h)
- #echo_help
- usage
- cleanup_and_exit
- ;;
- *-build)
- DOMAKE="1"
- BUILD_TYPE="${ARG}"
- test -n "${BUILD_TYPE}" && shift
- ;;
- *-clean)
- clean_build_dir
- cleanup_and_exit
- ;;
- *-clang)
- OPTIONS="${OPTIONS} -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++"
- ;;
- *-verbose)
- DOVERBOSE="1"
- ;;
- *-memtest)
- OPTIONS="${OPTIONS} -DMEM_NULL_TESTS=ON"
- ;;
- *-libsuffix)
- OPTIONS="${OPTIONS} -DLIB_SUFFIX=${ARG}"
- shift
- ;;
- *-prefix)
- OPTIONS="${OPTIONS} -DCMAKE_INSTALL_PREFIX=${ARG}"
- shift
- ;;
- *-sysconfdir)
- OPTIONS="${OPTIONS} -DSYSCONF_INSTALL_DIR=${ARG}"
- shift
- ;;
- *-cmakedir)
- CMAKEDIR="${ARG}"
- shift
- ;;
- *-make)
- MAKE="${ARG}"
- shift
- ;;
- *-ccompiler)
- OPTIONS="${OPTIONS} -DCMAKE_C_COMPILER=${ARG}"
- shift
- ;;
- *-withstaticlib)
- OPTIONS="${OPTIONS} -DWITH_STATIC_LIB=ON"
- ;;
- *-unittesting)
- OPTIONS="${OPTIONS} -DUNIT_TESTING=ON"
- ;;
- *-clientunittesting)
- OPTIONS="${OPTIONS} -DCLIENT_TESTING=ON"
- ;;
- *-withserver)
- OPTIONS="${OPTIONS} -DWITH_SERVER=ON"
- ;;
- *-withoutsymbolversioning)
- OPTIONS="${OPTIONS} -DWITH_SYMBOL_VERSIONING=OFF"
- ;;
- *-finalrelease)
- OPTIONS="${OPTIONS} -DWITH_FINAL=ON"
- ;;
- ----noarg)
- echo "$ARG does not take an argument"
- cleanup_and_exit
- ;;
- -*)
- echo Unknown Option "$PARAM". Exit.
- cleanup_and_exit 1
- ;;
- *)
- usage
- ;;
- esac
-done
-
-if [ "${DOMAKE}" == "1" ]; then
- OPTIONS="${OPTIONS} -DCMAKE_BUILD_TYPE=${BUILD_TYPE}"
-fi
-
-if [ -n "${DOVERBOSE}" ]; then
- OPTIONS="${OPTIONS} -DCMAKE_VERBOSE_MAKEFILE=1"
-else
- OPTIONS="${OPTIONS} -DCMAKE_VERBOSE_MAKEFILE=0"
-fi
-
-test -f "${BUILDDIR}/.build.log" && rm -f ${BUILDDIR}/.build.log
-touch ${BUILDDIR}/.build.log
-# log everything from here to .build.log
-exec 1> >(exec -a 'build logging tee' tee -a ${BUILDDIR}/.build.log) 2>&1
-echo "${HOST} started build at $(date)."
-echo
-
-configure ${OPTIONS} "$@"
-
-if [ -n "${DOMAKE}" ]; then
- test -n "${DOVERBOSE}" && compile VERBOSE=1 || compile
-fi
-
-DOT=$(which dot 2>/dev/null)
-if [ -n "${DOT}" ]; then
- ${DOT} -Tpng -o${BUILDDIR}/libssh.png ${BUILDDIR}/libssh.dot
- ${DOT} -Tsvg -o${BUILDDIR}/libssh.svg ${BUILDDIR}/libssh.dot
-fi
-
-exec >&0 2>&0 # so that the logging tee finishes
-sleep 1 # wait till tee terminates
-
-cleanup_and_exit 0
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 04d3719f..5904ac67 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -88,11 +88,6 @@ if (WITH_NACL AND NACL_FOUND)
)
endif (WITH_NACL AND NACL_FOUND)
-set(LIBSSH_SHARED_LIBRARY
- ssh_shared
- CACHE INTERNAL "libssh shared library"
-)
-
if (BUILD_STATIC_LIB)
set(LIBSSH_STATIC_LIBRARY
ssh_static
@@ -314,51 +309,52 @@ if (WITH_SYMBOL_VERSIONING AND HAVE_LD_VERSION_SCRIPT AND ABIMAP_FOUND)
)
endif (WITH_SYMBOL_VERSIONING AND HAVE_LD_VERSION_SCRIPT AND ABIMAP_FOUND)
-add_library(${LIBSSH_SHARED_LIBRARY} SHARED ${libssh_SRCS})
-target_compile_options(${LIBSSH_SHARED_LIBRARY}
+# This gets built as a static library, if -DBUILD_SHARED_LIBS=OFF is passed to
+# cmake.
+add_library(ssh ${libssh_SRCS})
+target_compile_options(ssh
PRIVATE
${DEFAULT_C_COMPILE_FLAGS}
-D_GNU_SOURCE)
-target_include_directories(${LIBSSH_SHARED_LIBRARY}
+target_include_directories(ssh
PRIVATE ${LIBSSH_PUBLIC_INCLUDE_DIRS} ${LIBSSH_PRIVATE_INCLUDE_DIRS})
-target_link_libraries(${LIBSSH_SHARED_LIBRARY}
+target_link_libraries(ssh
PRIVATE ${LIBSSH_LINK_LIBRARIES})
+add_library(ssh::ssh ALIAS ssh)
+
if (WITH_SYMBOL_VERSIONING AND HAVE_LD_VERSION_SCRIPT)
if (ABIMAP_FOUND)
# Change path to devel map file
set(MAP_PATH "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}_dev.map")
endif (ABIMAP_FOUND)
- set_target_properties(${LIBSSH_SHARED_LIBRARY}
+ set_target_properties(ssh
PROPERTIES LINK_FLAGS
"-Wl,--version-script,\"${MAP_PATH}\"")
endif (WITH_SYMBOL_VERSIONING AND HAVE_LD_VERSION_SCRIPT)
-set_target_properties(
- ${LIBSSH_SHARED_LIBRARY}
+set_target_properties(ssh
PROPERTIES
VERSION
${LIBRARY_VERSION}
SOVERSION
${LIBRARY_SOVERSION}
- OUTPUT_NAME
- ssh
DEFINE_SYMBOL
LIBSSH_EXPORTS
)
if (WITH_VISIBILITY_HIDDEN)
- set_target_properties(${LIBSSH_SHARED_LIBRARY} PROPERTIES COMPILE_FLAGS "-fvisibility=hidden")
+ set_target_properties(ssh PROPERTIES COMPILE_FLAGS "-fvisibility=hidden")
endif (WITH_VISIBILITY_HIDDEN)
if (MINGW)
- set_target_properties(${LIBSSH_SHARED_LIBRARY} PROPERTIES LINK_FLAGS "-Wl,--enable-stdcall-fixup")
+ set_target_properties(ssh PROPERTIES LINK_FLAGS "-Wl,--enable-stdcall-fixup")
endif ()
-install(TARGETS ${LIBSSH_SHARED_LIBRARY}
+install(TARGETS ssh
EXPORT libssh-config
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 8ee2deef..36d757bc 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -91,7 +91,7 @@ if (CLIENT_TESTING)
# ssh_ping
add_executable(ssh_ping ssh_ping.c)
target_compile_options(ssh_ping PRIVATE ${DEFAULT_C_COMPILE_FLAGS})
- target_link_libraries(ssh_ping ${LIBSSH_SHARED_LIBRARY})
+ target_link_libraries(ssh_ping ssh::ssh)
# homedir will be used in passwd
set(HOMEDIR ${CMAKE_CURRENT_BINARY_DIR}/home)
diff --git a/tests/benchmarks/CMakeLists.txt b/tests/benchmarks/CMakeLists.txt
index 8dc8552f..b8d7cfed 100644
--- a/tests/benchmarks/CMakeLists.txt
+++ b/tests/benchmarks/CMakeLists.txt
@@ -10,12 +10,4 @@ include_directories(
add_executable(benchmarks ${benchmarks_SRCS})
-target_link_libraries(benchmarks ${LIBSSH_SHARED_LIBRARY})
-
-include_directories(
- ${LIBSSH_PUBLIC_INCLUDE_DIRS}
- ${CMAKE_BINARY_DIR}
-)
-
-if (WITH_SFTP)
-endif (WITH_SFTP)
+target_link_libraries(benchmarks ssh::ssh)
diff --git a/tests/server/test_server/CMakeLists.txt b/tests/server/test_server/CMakeLists.txt
index cc8ed6f0..57edd3f4 100644
--- a/tests/server/test_server/CMakeLists.txt
+++ b/tests/server/test_server/CMakeLists.txt
@@ -30,7 +30,7 @@ if (UNIX AND NOT WIN32)
target_compile_options(test_server PRIVATE ${DEFAULT_C_COMPILE_FLAGS})
target_link_libraries(test_server
testserver
- ${LIBSSH_SHARED_LIBRARY}
+ ssh::ssh
${ARGP_LIBRARY}
util)
endif ()