cmake: drop libssh CONFIG-style detection

Drop `find_package(libssh CONFIG)` detection method in favour of
the Find module that supports both `pkg-config`, and CMake-native
(since #14555) detection.

This aligns `libssh` detection with other dependencies. It makes the
build honor custom configuration via `LIBSSH_INCLUDE_DIR`,
`LIBSSH_LIBRARY`.

Also enable libssh in a GHA/macos cmake job for build coverage.

Fixing:
- curl-for-win requiring a hack to configure libssh:
  4f9acbed92/curl.sh (L255-L263)
- after #14555, GHA/windows gnutls vcpkg job no longer auto-detected
  libssh, due to a regression missing to enable libssh when
  found via `find_package(libssh CONFIG)`.
  Ref: https://github.com/curl/curl/actions/runs/10470138955/job/28994650338

Follow-up to 422696f0a4 #14555

Closes #14614
This commit is contained in:
Viktor Szakats 2024-08-20 15:44:28 +02:00
parent 778391334e
commit 576b39b6d0
No known key found for this signature in database
GPG Key ID: B5ABD165E2AEF201
2 changed files with 9 additions and 13 deletions

View File

@ -278,8 +278,9 @@ jobs:
install: gsasl
generate: -DOPENSSL_ROOT_DIR=$(brew --prefix openssl) -DCURL_USE_GSASL=ON -DUSE_APPLE_IDN=ON -DENABLE_WEBSOCKETS=ON
macos-version-min: '10.9'
- name: 'OpenSSL +static'
generate: -DOPENSSL_ROOT_DIR=$(brew --prefix openssl) -DBUILD_STATIC_LIBS=ON
- name: 'OpenSSL +static libssh'
install: libssh
generate: -DOPENSSL_ROOT_DIR=$(brew --prefix openssl) -DBUILD_STATIC_LIBS=ON -DCURL_USE_LIBSSH2=OFF -DCURL_USE_LIBSSH=ON
macos-version-min: '10.9'
- name: 'SecureTransport ws debug+'
generate: -DCURL_USE_SECTRANSP=ON -DENABLE_WEBSOCKETS=ON -DENABLE_DEBUG=ON -DENABLE_CURLDEBUG=ON

View File

@ -1066,17 +1066,12 @@ endif()
option(CURL_USE_LIBSSH "Use libssh" OFF)
mark_as_advanced(CURL_USE_LIBSSH)
if(NOT USE_LIBSSH2 AND CURL_USE_LIBSSH)
find_package(libssh CONFIG QUIET)
if(libssh_FOUND)
message(STATUS "Found libssh ${libssh_VERSION}")
else()
find_package(Libssh REQUIRED)
if(LIBSSH_FOUND)
list(APPEND CURL_LIBS ${LIBSSH_LIBRARIES})
list(APPEND LIBCURL_PC_REQUIRES_PRIVATE "libssh")
include_directories(${LIBSSH_INCLUDE_DIRS})
set(USE_LIBSSH ON)
endif()
find_package(Libssh REQUIRED)
if(LIBSSH_FOUND)
list(APPEND CURL_LIBS ${LIBSSH_LIBRARIES})
list(APPEND LIBCURL_PC_REQUIRES_PRIVATE "libssh")
include_directories(${LIBSSH_INCLUDE_DIRS})
set(USE_LIBSSH ON)
endif()
endif()