mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 14:16:07 -06:00
Core/SSH: Minor SFtpStream improvements, bug fixes, cleanup.
git-svn-id: svn://ultimatepp.org/upp/trunk@15438 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
414c337807
commit
df024471d3
7 changed files with 33 additions and 529 deletions
|
|
@ -93,21 +93,17 @@ bool Ssh::Run(Gate<>&& fn)
|
|||
|
||||
void Ssh::Wait()
|
||||
{
|
||||
// Here we disregard libssh2's socket event flags, and always wait for "any"
|
||||
// socket event. Because we might have multiple channels waiting on the same
|
||||
// session socket simutaneously (in MT). In those cases, waiting for a single
|
||||
// event could lead the waiting channels to timeout errors. This way we give
|
||||
// them a chance to fetch or send their data.
|
||||
|
||||
while(!IsTimeout()) {
|
||||
RefreshUI();
|
||||
if(!ssh->socket)
|
||||
return;
|
||||
SocketWaitEvent we;
|
||||
we.Add(*ssh->socket, WAIT_READ|WAIT_WRITE);
|
||||
if(we.Wait(ssh->waitstep) || ssh->noblock)
|
||||
return;
|
||||
}
|
||||
RefreshUI();
|
||||
if(!ssh->socket || !ssh->session)
|
||||
return;
|
||||
dword q = 0, r = libssh2_session_block_directions(ssh->session);
|
||||
if(r & LIBSSH2_SESSION_BLOCK_INBOUND)
|
||||
q |= WAIT_READ;
|
||||
if(r & LIBSSH2_SESSION_BLOCK_OUTBOUND)
|
||||
q |= WAIT_WRITE;
|
||||
SocketWaitEvent we;
|
||||
we.Add(*ssh->socket, q);
|
||||
we.Wait(ssh->waitstep);
|
||||
}
|
||||
|
||||
void Ssh::SetError(int rc, const String& reason)
|
||||
|
|
@ -145,7 +141,6 @@ Ssh::Ssh()
|
|||
ssh->session = nullptr;
|
||||
ssh->socket = nullptr;
|
||||
ssh->init = false;
|
||||
ssh->noblock = false;
|
||||
ssh->timeout = Null;
|
||||
ssh->start_time = 0;
|
||||
ssh->waitstep = 10;
|
||||
|
|
|
|||
|
|
@ -47,7 +47,6 @@ protected:
|
|||
int waitstep;
|
||||
int chunk_size;
|
||||
int status;
|
||||
bool noblock;
|
||||
};
|
||||
One<CoreData> ssh;
|
||||
|
||||
|
|
|
|||
|
|
@ -111,11 +111,11 @@ bool SFtp::Sync(SFtpHandle handle)
|
|||
|
||||
SFtp& SFtp::Seek(SFtpHandle handle, int64 position)
|
||||
{
|
||||
Run([=] () mutable {
|
||||
INTERLOCKED
|
||||
{
|
||||
LLOG("Seeking to offset: " << position);
|
||||
libssh2_sftp_seek64(handle, position);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
@ -123,11 +123,11 @@ int64 SFtp::GetPos(SFtpHandle handle)
|
|||
{
|
||||
int64 pos = 0;
|
||||
|
||||
Run([=, &pos] () mutable {
|
||||
INTERLOCKED
|
||||
{
|
||||
pos = libssh2_sftp_tell64(handle);
|
||||
LLOG("File position: " << pos);
|
||||
return true;
|
||||
});
|
||||
};
|
||||
return pos;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,15 +15,16 @@ void SFtpStream::SetStreamSize(int64 size)
|
|||
dword SFtpStream::Read(int64 at, void *ptr, dword size)
|
||||
{
|
||||
SetPos(at);
|
||||
return sftp->Get(handle, ptr, size);
|
||||
int n = sftp->Get(handle, ptr, size);
|
||||
if(sftp->IsError()) SetError();
|
||||
return dword(n);
|
||||
}
|
||||
|
||||
void SFtpStream::Write(int64 at, const void *data, dword size)
|
||||
{
|
||||
SetPos(at);
|
||||
sftp->Put(handle, data, size);
|
||||
if(sftp->IsError())
|
||||
SetError();
|
||||
if(sftp->IsError()) SetError();
|
||||
}
|
||||
|
||||
void SFtpStream::Close()
|
||||
|
|
@ -31,7 +32,7 @@ void SFtpStream::Close()
|
|||
if(handle) {
|
||||
Flush();
|
||||
sftp->Close(handle);
|
||||
handle = NULL;
|
||||
handle = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -46,13 +47,20 @@ bool SFtpStream::Open(SFtp& sftp_, const char *filename, dword mode, int acm)
|
|||
Close();
|
||||
sftp = &sftp_;
|
||||
int iomode = mode & ~SHAREMASK;
|
||||
handle = sftp->Open(filename, iomode == READ ? SFtp::READ :
|
||||
iomode == CREATE ? SFtp::READ|SFtp::WRITE|SFtp::CREATE|SFtp::TRUNCATE :
|
||||
SFtp::READ|SFtp::WRITE, acm);
|
||||
handle = sftp->Open(filename,
|
||||
iomode == READ
|
||||
? SFtp::READ
|
||||
: iomode == CREATE
|
||||
? SFtp::READ|SFtp::WRITE|SFtp::CREATE|SFtp::TRUNCATE
|
||||
: SFtp::READ|SFtp::WRITE,
|
||||
acm
|
||||
);
|
||||
|
||||
if(handle) {
|
||||
SFtpAttrs attrs;
|
||||
if(!sftp->GetAttrs(handle, attrs)) {
|
||||
Close();
|
||||
sftp->Close(handle);
|
||||
handle = nullptr;
|
||||
return false;
|
||||
}
|
||||
OpenInit(mode, attrs.filesize);
|
||||
|
|
|
|||
|
|
@ -373,7 +373,6 @@ SshShell::SshShell(SshSession& session)
|
|||
#endif
|
||||
{
|
||||
ssh->otype = SHELL;
|
||||
ssh->noblock = true;
|
||||
Zero(tflags);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,432 +0,0 @@
|
|||
# Copyright (c) 2014 Alexander Lamaison <alexander.lamaison@gmail.com>
|
||||
#
|
||||
# Redistribution and use in source and binary forms,
|
||||
# with or without modification, are permitted provided
|
||||
# that the following conditions are met:
|
||||
#
|
||||
# Redistributions of source code must retain the above
|
||||
# copyright notice, this list of conditions and the
|
||||
# following disclaimer.
|
||||
#
|
||||
# Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following
|
||||
# disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# Neither the name of the copyright holder nor the names
|
||||
# of any other contributors may be used to endorse or
|
||||
# promote products derived from this software without
|
||||
# specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
# OF SUCH DAMAGE.
|
||||
|
||||
include(CheckFunctionExists)
|
||||
include(CheckSymbolExists)
|
||||
include(CheckFunctionExistsMayNeedLibrary)
|
||||
include(CheckIncludeFiles)
|
||||
include(CheckTypeSize)
|
||||
include(CheckSymbolExists)
|
||||
include(CheckNonblockingSocketSupport)
|
||||
include(SocketLibraries)
|
||||
|
||||
## Cryptography backend choice
|
||||
|
||||
set(CRYPTO_BACKEND
|
||||
""
|
||||
CACHE
|
||||
STRING
|
||||
"The backend to use for cryptography: OpenSSL, Libgcrypt or WinCNG, mbedTLS
|
||||
or empty to try any available")
|
||||
|
||||
# If the crypto backend was given, rather than searching for the first
|
||||
# we are able to find, the find_package commands must abort configuration
|
||||
# and report to the user.
|
||||
if(CRYPTO_BACKEND)
|
||||
set(SPECIFIC_CRYPTO_REQUIREMENT REQUIRED)
|
||||
endif()
|
||||
|
||||
if(CRYPTO_BACKEND STREQUAL "OpenSSL" OR NOT CRYPTO_BACKEND)
|
||||
|
||||
find_package(OpenSSL ${SPECIFIC_CRYPTO_REQUIREMENT})
|
||||
|
||||
if(OPENSSL_FOUND)
|
||||
set(CRYPTO_BACKEND "OpenSSL")
|
||||
set(CRYPTO_SOURCES openssl.c openssl.h)
|
||||
list(APPEND PRIVATE_COMPILE_DEFINITIONS LIBSSH2_OPENSSL)
|
||||
list(APPEND PRIVATE_INCLUDE_DIRECTORIES ${OPENSSL_INCLUDE_DIR})
|
||||
list(APPEND LIBRARIES ${OPENSSL_LIBRARIES})
|
||||
list(APPEND PC_REQUIRES_PRIVATE libssl libcrypto)
|
||||
|
||||
if (WIN32)
|
||||
# Statically linking to OpenSSL requires crypt32 for some Windows APIs.
|
||||
# This should really be handled by FindOpenSSL.cmake.
|
||||
list(APPEND LIBRARIES crypt32)
|
||||
list(APPEND PC_LIBS -lcrypt32)
|
||||
|
||||
find_file(DLL_LIBEAY32
|
||||
NAMES libeay32.dll crypto.dll libcrypto-1_1.dll libcrypto-1_1-x64.dll
|
||||
HINTS ${_OPENSSL_ROOT_HINTS} PATHS ${_OPENSSL_ROOT_PATHS}
|
||||
PATH_SUFFIXES bin)
|
||||
if (NOT DLL_LIBEAY32)
|
||||
message(WARNING
|
||||
"Unable to find OpenSSL crypto (aka libeay32) DLL, executables may not run")
|
||||
endif()
|
||||
|
||||
find_file(DLL_SSLEAY32
|
||||
NAMES ssleay32.dll ssl.dll libssl-1_1.dll libssl-1_1-x64.dll
|
||||
HINTS ${_OPENSSL_ROOT_HINTS} PATHS ${_OPENSSL_ROOT_PATHS}
|
||||
PATH_SUFFIXES bin)
|
||||
if (NOT DLL_SSLEAY32)
|
||||
message(WARNING
|
||||
"Unable to find OpenSSL ssl (aka ssleay32) DLL, executables may not run")
|
||||
endif()
|
||||
|
||||
if(DLL_LIBEAY32 AND DLL_SSLEAY32)
|
||||
list(APPEND _RUNTIME_DEPENDENCIES ${DLL_LIBEAY32} ${DLL_SSLEAY32})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Not all OpenSSL have AES-CTR functions.
|
||||
set(SAVE_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_LIBRARIES})
|
||||
check_function_exists(EVP_aes_128_ctr HAVE_EVP_AES_128_CTR)
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${SAVE_CMAKE_REQUIRED_LIBRARIES})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(CRYPTO_BACKEND STREQUAL "Libgcrypt" OR NOT CRYPTO_BACKEND)
|
||||
|
||||
find_package(Libgcrypt ${SPECIFIC_CRYPTO_REQUIREMENT})
|
||||
|
||||
if(LIBGCRYPT_FOUND)
|
||||
set(CRYPTO_BACKEND "Libgcrypt")
|
||||
set(CRYPTO_SOURCES libgcrypt.c libgcrypt.h)
|
||||
list(APPEND PRIVATE_COMPILE_DEFINITIONS LIBSSH2_LIBGCRYPT)
|
||||
list(APPEND PRIVATE_INCLUDE_DIRECTORIES ${LIBGCRYPT_INCLUDE_DIRS})
|
||||
list(APPEND LIBRARIES ${LIBGCRYPT_LIBRARIES})
|
||||
list(APPEND PC_LIBS -lgcrypt)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(CRYPTO_BACKEND STREQUAL "WinCNG" OR NOT CRYPTO_BACKEND)
|
||||
|
||||
# The check actually compiles the header. This requires windows.h.
|
||||
check_include_files("windows.h;bcrypt.h" HAVE_BCRYPT_H)
|
||||
|
||||
if(HAVE_BCRYPT_H)
|
||||
set(CRYPTO_BACKEND "WinCNG")
|
||||
set(CRYPTO_SOURCES wincng.c wincng.h)
|
||||
list(APPEND PRIVATE_COMPILE_DEFINITIONS LIBSSH2_WINCNG)
|
||||
|
||||
set(HAVE_LIBCRYPT32 TRUE)
|
||||
list(APPEND LIBRARIES bcrypt)
|
||||
list(APPEND PC_LIBS -lbcrypt)
|
||||
|
||||
check_include_files(ntdef.h HAVE_NTDEF_H)
|
||||
check_include_files(ntstatus.h HAVE_NTSTATUS_H)
|
||||
|
||||
# Reading keys from files is optional and depends on Wincrypt
|
||||
check_include_files("windows.h;wincrypt.h" HAVE_WINCRYPT_H)
|
||||
|
||||
if(HAVE_WINCRYPT_H)
|
||||
list(APPEND LIBRARIES crypt32)
|
||||
list(APPEND PC_LIBS -lcrypt32)
|
||||
endif()
|
||||
|
||||
elseif(${SPECIFIC_CRYPTO_REQUIREMENT} STREQUAL ${REQUIRED})
|
||||
message(FATAL_ERROR "WinCNG not available")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(CRYPTO_BACKEND STREQUAL "mbedTLS" OR NOT CRYPTO_BACKEND)
|
||||
|
||||
find_package(mbedTLS ${SPECIFIC_CRYPTO_REQUIREMENT})
|
||||
|
||||
if(MBEDTLS_FOUND)
|
||||
set(CRYPTO_BACKEND "mbedTLS")
|
||||
set(CRYPTO_SOURCES mbedtls.c mbedtls.h)
|
||||
list(APPEND PRIVATE_COMPILE_DEFINITIONS LIBSSH2_MBEDTLS)
|
||||
list(APPEND PRIVATE_INCLUDE_DIRECTORIES ${MBEDTLS_INCLUDE_DIR})
|
||||
list(APPEND LIBRARIES ${MBEDTLS_LIBRARIES})
|
||||
list(APPEND PC_LIBS -lmbedcrypto)
|
||||
link_directories(${MBEDTLS_LIBRARY_DIR})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT CRYPTO_BACKEND)
|
||||
message(FATAL_ERROR "No suitable cryptography backend found.")
|
||||
endif()
|
||||
|
||||
## Library definition
|
||||
|
||||
include(GNUInstallDirs)
|
||||
set(SOURCES
|
||||
${CRYPTO_SOURCES}
|
||||
agent.c
|
||||
blf.h
|
||||
bcrypt_pbkdf.c
|
||||
blowfish.c
|
||||
channel.c
|
||||
channel.h
|
||||
comp.c
|
||||
comp.h
|
||||
crypt.c
|
||||
crypto.h
|
||||
global.c
|
||||
hostkey.c
|
||||
keepalive.c
|
||||
kex.c
|
||||
knownhost.c
|
||||
libssh2_priv.h
|
||||
mac.c
|
||||
mac.h
|
||||
misc.c
|
||||
misc.h
|
||||
packet.c
|
||||
packet.h
|
||||
pem.c
|
||||
publickey.c
|
||||
scp.c
|
||||
session.c
|
||||
session.h
|
||||
sftp.c
|
||||
sftp.h
|
||||
transport.c
|
||||
transport.h
|
||||
userauth.c
|
||||
userauth.h
|
||||
version.c)
|
||||
|
||||
if(WIN32)
|
||||
list(APPEND SOURCES ${PROJECT_SOURCE_DIR}/win32/libssh2.rc)
|
||||
endif()
|
||||
|
||||
add_library(libssh2 ${SOURCES})
|
||||
# we want it to be called libssh2 on all platforms
|
||||
set_target_properties(libssh2 PROPERTIES PREFIX "")
|
||||
|
||||
target_compile_definitions(libssh2 PRIVATE ${PRIVATE_COMPILE_DEFINITIONS})
|
||||
target_include_directories(libssh2
|
||||
PRIVATE "${PROJECT_SOURCE_DIR}/include/" ${PRIVATE_INCLUDE_DIRECTORIES}
|
||||
PUBLIC
|
||||
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
|
||||
$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}>)
|
||||
|
||||
## Options
|
||||
|
||||
option(CLEAR_MEMORY "Enable clearing of memory before being freed" ON)
|
||||
if(CLEAR_MEMORY)
|
||||
add_definitions(-DLIBSSH2_CLEAR_MEMORY)
|
||||
endif(CLEAR_MEMORY)
|
||||
|
||||
add_feature_info("Shared library" BUILD_SHARED_LIBS
|
||||
"creating libssh2 as a shared library (.so/.dll)")
|
||||
|
||||
option(ENABLE_ZLIB_COMPRESSION "Use zlib for compression")
|
||||
add_feature_info(Compression ENABLE_ZLIB_COMPRESSION
|
||||
"using zlib for compression")
|
||||
if(ENABLE_ZLIB_COMPRESSION)
|
||||
find_package(ZLIB REQUIRED)
|
||||
|
||||
target_include_directories(libssh2 PRIVATE ${ZLIB_INCLUDE_DIRS})
|
||||
list(APPEND LIBRARIES ${ZLIB_LIBRARIES})
|
||||
list(APPEND PC_REQUIRES_PRIVATE zlib)
|
||||
if(ZLIB_FOUND)
|
||||
target_compile_definitions(libssh2 PRIVATE LIBSSH2_HAVE_ZLIB=1)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
option(ENABLE_CRYPT_NONE "Permit \"none\" cipher -- NOT RECOMMENDED")
|
||||
add_feature_info("\"none\" cipher" ENABLE_CRYPT_NONE "")
|
||||
if(ENABLE_CRYPT_NONE)
|
||||
target_compile_definitions(libssh2 PRIVATE LIBSSH2_CRYPT_NONE=1)
|
||||
endif()
|
||||
|
||||
option(ENABLE_MAC_NONE "Permit \"none\" MAC -- NOT RECOMMMENDED")
|
||||
add_feature_info("\"none\" MAC" ENABLE_MAC_NONE "")
|
||||
if(ENABLE_MAC_NONE)
|
||||
target_compile_definitions(libssh2 PRIVATE LIBSSH2_MAC_NONE=1)
|
||||
endif()
|
||||
|
||||
option(ENABLE_GEX_NEW
|
||||
"Enable diffie-hellman-group-exchange-sha1 method" ON)
|
||||
add_feature_info("diffie-hellman-group-exchange-sha1" ENABLE_GEX_NEW
|
||||
"\"new\" diffie-hellman-group-exchange-sha1 method")
|
||||
if(ENABLE_GEX_NEW)
|
||||
target_compile_definitions(libssh2 PRIVATE LIBSSH2_DH_GEX_NEW=1)
|
||||
endif()
|
||||
|
||||
# Enable debugging logging by default if the user configured a debug build
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
set(DEBUG_LOGGING_DEFAULT ON)
|
||||
else()
|
||||
set(DEBUG_LOGGING_DEFAULT OFF)
|
||||
endif()
|
||||
option(ENABLE_DEBUG_LOGGING "log execution with debug trace"
|
||||
${DEBUG_LOGGING_DEFAULT})
|
||||
add_feature_info(Logging ENABLE_DEBUG_LOGGING
|
||||
"Logging of execution with debug trace")
|
||||
if(ENABLE_DEBUG_LOGGING)
|
||||
target_compile_definitions(libssh2 PRIVATE LIBSSH2DEBUG)
|
||||
endif()
|
||||
|
||||
## Platform checks
|
||||
check_include_files(unistd.h HAVE_UNISTD_H)
|
||||
check_include_files(inttypes.h HAVE_INTTYPES_H)
|
||||
check_include_files(stdlib.h HAVE_STDLIB_H)
|
||||
check_include_files(sys/select.h HAVE_SYS_SELECT_H)
|
||||
|
||||
check_include_files(sys/uio.h HAVE_SYS_UIO_H)
|
||||
check_include_files(sys/socket.h HAVE_SYS_SOCKET_H)
|
||||
check_include_files(sys/ioctl.h HAVE_SYS_IOCTL_H)
|
||||
check_include_files(sys/time.h HAVE_SYS_TIME_H)
|
||||
check_include_files(sys/un.h HAVE_SYS_UN_H)
|
||||
check_include_files(windows.h HAVE_WINDOWS_H)
|
||||
check_include_files(ws2tcpip.h HAVE_WS2TCPIP_H)
|
||||
check_include_files(winsock2.h HAVE_WINSOCK2_H)
|
||||
|
||||
check_type_size("long long" LONGLONG)
|
||||
|
||||
if(HAVE_SYS_TIME_H)
|
||||
check_symbol_exists(gettimeofday sys/time.h HAVE_GETTIMEOFDAY)
|
||||
else()
|
||||
check_function_exists(gettimeofday HAVE_GETTIMEOFDAY)
|
||||
endif()
|
||||
if(HAVE_STDLIB_H)
|
||||
check_symbol_exists(strtoll stdlib.h HAVE_STRTOLL)
|
||||
else()
|
||||
check_function_exists(strtoll HAVE_STRTOLL)
|
||||
endif()
|
||||
if (NOT HAVE_STRTOLL)
|
||||
# Try _strtoi64 if strtoll isn't available
|
||||
check_symbol_exists(_strtoi64 stdlib.h HAVE_STRTOI64)
|
||||
endif()
|
||||
check_symbol_exists(snprintf stdio.h HAVE_SNPRINTF)
|
||||
check_symbol_exists(memset_s string.h HAVE_MEMSET_S)
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin" OR
|
||||
${CMAKE_SYSTEM_NAME} STREQUAL "Interix")
|
||||
# poll() does not work on these platforms
|
||||
#
|
||||
# Interix: "does provide poll(), but the implementing developer must
|
||||
# have been in a bad mood, because poll() only works on the /proc
|
||||
# filesystem here"
|
||||
#
|
||||
# Mac OS X's poll has funny behaviors, like:
|
||||
# not being able to do poll on no filedescriptors (10.3?)
|
||||
# not being able to poll on some files (like anything in /dev)
|
||||
# not having reliable timeout support
|
||||
# inconsistent return of POLLHUP where other implementations give POLLIN
|
||||
message("poll use is disabled on this platform")
|
||||
else()
|
||||
check_function_exists(poll HAVE_POLL)
|
||||
endif()
|
||||
|
||||
append_needed_socket_libraries(LIBRARIES)
|
||||
|
||||
# Non-blocking socket support tests. Must be after library tests to
|
||||
# link correctly
|
||||
set(SAVE_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${LIBRARIES})
|
||||
check_nonblocking_socket_support()
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${SAVE_CMAKE_REQUIRED_LIBRARIES})
|
||||
|
||||
configure_file(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/libssh2_config_cmake.h.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/libssh2_config.h)
|
||||
# to find generated header
|
||||
target_include_directories(libssh2 PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
# Check for the OS.
|
||||
# Daniel's note: this should not be necessary and we need to work to
|
||||
# get this removed.
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
|
||||
target_compile_definitions(libssh2 PRIVATE LIBSSH2_WIN32)
|
||||
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
|
||||
target_compile_definitions(libssh2 PRIVATE LIBSSH2_DARWIN)
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /Zi /Od")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} /DEBUG")
|
||||
endif()
|
||||
|
||||
if(CMAKE_VERSION VERSION_LESS "2.8.12")
|
||||
# Fall back to over-linking dependencies
|
||||
target_link_libraries(libssh2 ${LIBRARIES})
|
||||
else()
|
||||
target_link_libraries(libssh2 PRIVATE ${LIBRARIES})
|
||||
endif()
|
||||
|
||||
## Installation
|
||||
|
||||
install(FILES
|
||||
${PROJECT_SOURCE_DIR}/include/libssh2.h
|
||||
${PROJECT_SOURCE_DIR}/include/libssh2_publickey.h
|
||||
${PROJECT_SOURCE_DIR}/include/libssh2_sftp.h
|
||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
||||
|
||||
install(TARGETS libssh2
|
||||
EXPORT Libssh2Config
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
|
||||
if(BUILD_SHARED_LIBS)
|
||||
list(APPEND _RUNTIME_DEPENDENCIES $<TARGET_FILE:libssh2>)
|
||||
endif()
|
||||
|
||||
set(RUNTIME_DEPENDENCIES ${_RUNTIME_DEPENDENCIES} CACHE INTERNAL
|
||||
"Files that must be in the same directory as the executables at runtime.")
|
||||
|
||||
# Package config
|
||||
|
||||
## During package installation, install Libssh2Config.cmake
|
||||
install(EXPORT Libssh2Config
|
||||
NAMESPACE Libssh2::
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libssh2)
|
||||
|
||||
## During build, register directly from build tree
|
||||
# create Libssh2Config.cmake
|
||||
export(TARGETS libssh2 NAMESPACE Libssh2:: FILE Libssh2Config.cmake)
|
||||
export(PACKAGE Libssh2) # register it
|
||||
|
||||
## Export a .pc file for client projects not using CMaek
|
||||
if(PC_REQUIRES_PRIVATE)
|
||||
string(REPLACE ";" "," PC_REQUIRES_PRIVATE "${PC_REQUIRES_PRIVATE}")
|
||||
endif()
|
||||
if(PC_LIBS)
|
||||
string(REPLACE ";" " " PC_LIBS "${PC_LIBS}")
|
||||
endif()
|
||||
configure_file(libssh2.pc.in libssh2.pc @ONLY)
|
||||
install(
|
||||
FILES ${CMAKE_CURRENT_BINARY_DIR}/libssh2.pc
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
||||
|
||||
## Versioning
|
||||
|
||||
set_target_properties(libssh2 PROPERTIES
|
||||
SOVERSION 1
|
||||
VERSION 1.0.1)
|
||||
|
||||
include(CMakePackageConfigHelpers)
|
||||
write_basic_package_version_file(
|
||||
${CMAKE_CURRENT_BINARY_DIR}/Libssh2ConfigVersion.cmake
|
||||
VERSION "${LIBSSH2_VERSION_MAJOR}.${LIBSSH2_VERSION_MINOR}.${LIBSSH2_VERSION_PATCH}"
|
||||
COMPATIBILITY SameMajorVersion)
|
||||
install(
|
||||
FILES ${CMAKE_CURRENT_BINARY_DIR}/Libssh2ConfigVersion.cmake
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libssh2)
|
||||
|
|
@ -1,65 +0,0 @@
|
|||
# $Id: Makefile.am,v 1.21 2009/05/07 17:21:56 bagder Exp $
|
||||
AUTOMAKE_OPTIONS = foreign nostdinc
|
||||
|
||||
# Get the CRYPTO_CSOURCES, CRYPTO_HHEADERS and CRYPTO_LTLIBS defines
|
||||
if OPENSSL
|
||||
include ../Makefile.OpenSSL.inc
|
||||
endif
|
||||
if LIBGCRYPT
|
||||
include ../Makefile.libgcrypt.inc
|
||||
endif
|
||||
if WINCNG
|
||||
include ../Makefile.WinCNG.inc
|
||||
endif
|
||||
if MBEDTLS
|
||||
include ../Makefile.mbedTLS.inc
|
||||
endif
|
||||
|
||||
# Makefile.inc provides the CSOURCES and HHEADERS defines
|
||||
include ../Makefile.inc
|
||||
|
||||
libssh2_la_SOURCES = $(CSOURCES) $(HHEADERS)
|
||||
|
||||
EXTRA_DIST = libssh2_config.h.in libssh2_config_cmake.h.in libssh2.pc.in
|
||||
EXTRA_DIST += CMakeLists.txt NMakefile
|
||||
|
||||
lib_LTLIBRARIES = libssh2.la
|
||||
|
||||
# srcdir/include for the shipped headers
|
||||
# builddir/src for the generated config header when building out of the source
|
||||
# tree
|
||||
AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/src
|
||||
|
||||
VERSION=-version-info 1:1:0
|
||||
|
||||
# This flag accepts an argument of the form current[:revision[:age]]. So,
|
||||
# passing -version-info 3:12:1 sets current to 3, revision to 12, and age to
|
||||
# 1.
|
||||
#
|
||||
# If either revision or age are omitted, they default to 0. Also note that age
|
||||
# must be less than or equal to the current interface number.
|
||||
#
|
||||
# Here are a set of rules to help you update your library version information:
|
||||
#
|
||||
# 1.Start with version information of 0:0:0 for each libtool library.
|
||||
#
|
||||
# 2.Update the version information only immediately before a public release of
|
||||
# your software. More frequent updates are unnecessary, and only guarantee
|
||||
# that the current interface number gets larger faster.
|
||||
#
|
||||
# 3.If the library source code has changed at all since the last update, then
|
||||
# increment revision (c:r+1:a)
|
||||
#
|
||||
# 4.If any interfaces have been added, removed, or changed since the last
|
||||
# update, increment current, and set revision to 0. (c+1:r=0:a)
|
||||
#
|
||||
# 5.If any interfaces have been added since the last public release, then
|
||||
# increment age. (c:r:a+1)
|
||||
#
|
||||
# 6.If any interfaces have been removed since the last public release, then
|
||||
# set age to 0. (c:r:a=0)
|
||||
#
|
||||
|
||||
libssh2_la_LDFLAGS = $(VERSION) -no-undefined \
|
||||
-export-symbols-regex '^libssh2_.*' \
|
||||
$(CRYPTO_LTLIBS) $(LTLIBZ)
|
||||
Loading…
Add table
Add a link
Reference in a new issue