diff --git a/CMake/FindWolfSSH.cmake b/CMake/FindWolfSSH.cmake new file mode 100644 index 000000000..e6afbcc1c --- /dev/null +++ b/CMake/FindWolfSSH.cmake @@ -0,0 +1,56 @@ +#*************************************************************************** +# _ _ ____ _ +# Project ___| | | | _ \| | +# / __| | | | |_) | | +# | (__| |_| | _ <| |___ +# \___|\___/|_| \_\_____| +# +# Copyright (C) Daniel Stenberg, , et al. +# +# This software is licensed as described in the file COPYING, which +# you should have received as part of this distribution. The terms +# are also available at https://curl.se/docs/copyright.html. +# +# You may opt to use, copy, modify, merge, publish, distribute and/or sell +# copies of the Software, and permit persons to whom the Software is +# furnished to do so, under the terms of the COPYING file. +# +# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY +# KIND, either express or implied. +# +# SPDX-License-Identifier: curl +# +########################################################################### +# Find the wolfssh library +# +# Result Variables: +# +# WOLFSSH_FOUND System has wolfssh +# WOLFSSH_INCLUDE_DIRS The wolfssh include directories +# WOLFSSH_LIBRARIES The wolfssh library names +# WOLFSSH_VERSION Version of wolfssh + +find_path(WOLFSSH_INCLUDE_DIR "wolfssh/ssh.h") +find_library(WOLFSSH_LIBRARY NAMES "wolfssh" "libwolfssh") + +if(WOLFSSH_INCLUDE_DIR) + file(STRINGS "${WOLFSSH_INCLUDE_DIR}/wolfssh/version.h" _wolfssh_version_str REGEX "#[\t ]*define[\t ]+LIBWOLFSSH_VERSION_STRING[\t ]+\"(.*)\"") + string(REGEX REPLACE "^.*\"([^\"]+)\"" "\\1" WOLFSSH_VERSION "${_wolfssh_version_str}") + unset(_wolfssh_version_str) +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(WolfSSH + REQUIRED_VARS + WOLFSSH_INCLUDE_DIR + WOLFSSH_LIBRARY + VERSION_VAR + WOLFSSH_VERSION +) + +if(WOLFSSH_FOUND) + set(WOLFSSH_INCLUDE_DIRS ${WOLFSSH_INCLUDE_DIR}) + set(WOLFSSH_LIBRARIES ${WOLFSSH_LIBRARY}) +endif() + +mark_as_advanced(WOLFSSH_INCLUDE_DIR WOLFSSH_LIBRARY) diff --git a/CMakeLists.txt b/CMakeLists.txt index bbdc65ccf..44b0fe6fa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1097,6 +1097,24 @@ if(NOT USE_LIBSSH2 AND CURL_USE_LIBSSH) endif() endif() +# wolfSSH +option(CURL_USE_WOLFSSH "Use wolfssh" OFF) +mark_as_advanced(CURL_USE_WOLFSSH) +set(USE_WOLFSSH OFF) +if(NOT USE_LIBSSH2 AND NOT USE_LIBSSH AND CURL_USE_WOLFSSH) + if(USE_WOLFSSL) + find_package(WolfSSH) + if(WOLFSSH_FOUND) + list(APPEND CURL_LIBS ${WOLFSSH_LIBRARIES}) + list(APPEND CMAKE_REQUIRED_INCLUDES "${WOLFSSH_INCLUDE_DIRS}") + include_directories(${WOLFSSH_INCLUDE_DIRS}) + set(USE_WOLFSSH ON) + endif() + else() + message(WARNING "wolfSSH requires wolfSSL. Skipping.") + endif() +endif() + option(CURL_USE_GSASL "Use GSASL implementation" OFF) mark_as_advanced(CURL_USE_GSASL) if(CURL_USE_GSASL) @@ -1822,8 +1840,8 @@ if(NOT CURL_DISABLE_INSTALL) _use_curl_ntlm_core AND (SIZEOF_CURL_OFF_T GREATER 4)) _add_if("SMTP" NOT CURL_DISABLE_SMTP) _add_if("SMTPS" NOT CURL_DISABLE_SMTP AND _ssl_enabled) - _add_if("SCP" USE_LIBSSH2 OR USE_LIBSSH) - _add_if("SFTP" USE_LIBSSH2 OR USE_LIBSSH) + _add_if("SCP" USE_LIBSSH2 OR USE_LIBSSH OR USE_WOLFSSH) + _add_if("SFTP" USE_LIBSSH2 OR USE_LIBSSH OR USE_WOLFSSH) _add_if("RTSP" NOT CURL_DISABLE_RTSP) _add_if("RTMP" USE_LIBRTMP) _add_if("MQTT" NOT CURL_DISABLE_MQTT) diff --git a/Makefile.am b/Makefile.am index ee844268f..870cc9c37 100644 --- a/Makefile.am +++ b/Makefile.am @@ -45,6 +45,7 @@ CMAKE_DIST = \ CMake/FindNGTCP2.cmake \ CMake/FindNettle.cmake \ CMake/FindQUICHE.cmake \ + CMake/FindWolfSSH.cmake \ CMake/FindWolfSSL.cmake \ CMake/FindZstd.cmake \ CMake/Findrustls.cmake \ diff --git a/lib/curl_config.h.cmake b/lib/curl_config.h.cmake index 611e8dcff..80a4e03a7 100644 --- a/lib/curl_config.h.cmake +++ b/lib/curl_config.h.cmake @@ -707,6 +707,9 @@ ${SIZEOF_TIME_T_CODE} /* if libssh2 is in use */ #cmakedefine USE_LIBSSH2 1 +/* if wolfssh is in use */ +#cmakedefine USE_WOLFSSH 1 + /* if libpsl is in use */ #cmakedefine USE_LIBPSL 1