2020-03-23 21:44:29 +08:00
|
|
|
#***************************************************************************
|
|
|
|
# _ _ ____ _
|
|
|
|
# Project ___| | | | _ \| |
|
|
|
|
# / __| | | | |_) | |
|
|
|
|
# | (__| |_| | _ <| |___
|
|
|
|
# \___|\___/|_| \_\_____|
|
|
|
|
#
|
2023-01-02 20:51:48 +08:00
|
|
|
# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
|
2020-03-23 21:44:29 +08:00
|
|
|
#
|
|
|
|
# This software is licensed as described in the file COPYING, which
|
|
|
|
# you should have received as part of this distribution. The terms
|
2020-11-04 21:02:01 +08:00
|
|
|
# are also available at https://curl.se/docs/copyright.html.
|
2020-03-23 21:44:29 +08:00
|
|
|
#
|
|
|
|
# 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
|
2022-05-17 17:16:50 +08:00
|
|
|
#
|
2020-03-23 21:44:29 +08:00
|
|
|
###########################################################################
|
2024-08-05 02:35:13 +08:00
|
|
|
# Find the libssh2 library
|
2014-08-06 20:50:40 +08:00
|
|
|
#
|
2024-08-05 02:35:13 +08:00
|
|
|
# Result Variables:
|
|
|
|
#
|
2024-08-14 09:09:08 +08:00
|
|
|
# LIBSSH2_FOUND System has libssh2
|
|
|
|
# LIBSSH2_INCLUDE_DIRS The libssh2 include directories
|
|
|
|
# LIBSSH2_LIBRARIES The libssh2 library names
|
|
|
|
# LIBSSH2_VERSION Version of libssh2
|
2014-08-06 20:50:40 +08:00
|
|
|
|
2024-08-13 17:20:00 +08:00
|
|
|
if(CURL_USE_PKGCONFIG)
|
|
|
|
find_package(PkgConfig QUIET)
|
|
|
|
pkg_search_module(PC_LIBSSH2 "libssh2")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
find_path(LIBSSH2_INCLUDE_DIR "libssh2.h"
|
|
|
|
HINTS
|
|
|
|
${PC_LIBSSH2_INCLUDEDIR}
|
|
|
|
${PC_LIBSSH2_INCLUDE_DIRS}
|
|
|
|
)
|
2014-08-06 20:50:40 +08:00
|
|
|
|
2024-08-13 17:20:00 +08:00
|
|
|
find_library(LIBSSH2_LIBRARY NAMES "ssh2" "libssh2"
|
|
|
|
HINTS
|
|
|
|
${PC_LIBSSH2_LIBDIR}
|
|
|
|
${PC_LIBSSH2_LIBRARY_DIRS}
|
|
|
|
)
|
2014-08-06 20:50:40 +08:00
|
|
|
|
2024-08-14 04:59:50 +08:00
|
|
|
if(PC_LIBSSH2_VERSION)
|
|
|
|
set(LIBSSH2_VERSION ${PC_LIBSSH2_VERSION})
|
|
|
|
elseif(LIBSSH2_INCLUDE_DIR)
|
2024-08-05 02:35:13 +08:00
|
|
|
file(STRINGS "${LIBSSH2_INCLUDE_DIR}/libssh2.h" _libssh2_version_str REGEX "^#define[\t ]+LIBSSH2_VERSION[\t ]+\"(.*)\"")
|
2024-08-13 16:45:37 +08:00
|
|
|
string(REGEX REPLACE "^.*\"([^\"]+)\"" "\\1" LIBSSH2_VERSION "${_libssh2_version_str}")
|
cmake: tidy up Find modules
Smoothen out minor differences between Find modules.
- brotli, nghttp2: drop redundant `FOUND_VAR` specifiers from
`find_package_handle_standard_args()` calls.
This function sets both `<NAME_UPPER>_FOUND` and `<NAME>_FOUND`
by default.
- brotli: set result vars only when found.
- brotli: add missing `mark_as_advanced()` call.
- brotli: delete custom fail message.
- mbedtls, bearssl: use `REQUIRED_VARS` instead of `DEFAULT_MSG`.
- msh3, quiche: set `<NAME>_VERSION` (via pkg-config).
- wolfssl: also use `PC_WOLFSSL_INCLUDEDIR`, `PC_WOLFSSL_LIBDIR`
as hints.
- libpsl, libssh2, zstd: clear temporary variables used for version
detection.
- gss, msh3, nghttp2, nghttp3, ngtcp2, quiche, zstd: fix to apply
`mark_as_advanced()` to internal variables only.
Closes #14538
2024-08-14 04:31:21 +08:00
|
|
|
unset(_libssh2_version_str)
|
2018-07-17 14:36:59 +08:00
|
|
|
endif()
|
2014-08-06 20:50:40 +08:00
|
|
|
|
|
|
|
include(FindPackageHandleStandardArgs)
|
2020-02-24 20:34:54 +08:00
|
|
|
find_package_handle_standard_args(LibSSH2
|
2024-08-05 02:35:13 +08:00
|
|
|
REQUIRED_VARS
|
|
|
|
LIBSSH2_INCLUDE_DIR
|
|
|
|
LIBSSH2_LIBRARY
|
|
|
|
VERSION_VAR
|
|
|
|
LIBSSH2_VERSION
|
|
|
|
)
|
2014-08-06 20:50:40 +08:00
|
|
|
|
2024-08-14 09:09:08 +08:00
|
|
|
if(LIBSSH2_FOUND)
|
|
|
|
set(LIBSSH2_INCLUDE_DIRS ${LIBSSH2_INCLUDE_DIR})
|
|
|
|
set(LIBSSH2_LIBRARIES ${LIBSSH2_LIBRARY})
|
|
|
|
endif()
|
|
|
|
|
2020-02-24 20:34:54 +08:00
|
|
|
mark_as_advanced(LIBSSH2_INCLUDE_DIR LIBSSH2_LIBRARY)
|