From: Viktor Szakats Date: Tue, 16 Jul 2024 10:48:13 +0000 (+0200) Subject: cmake: detect `libssh` via `pkg-config` X-Git-Tag: curl-8_9_1~18 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e8acb2e55a648b81905dde3d220128356f723ed3;p=thirdparty%2Fcurl.git cmake: detect `libssh` via `pkg-config` Also: - fix broken libssh `pkg-config` behaviour on old Linux. (when found, `LIBSSH_LINK_LIBRARIES` remains undefined.) - delete manual libssh config from Old Linux CI job, it's no longer necessary. Closes #14199 --- diff --git a/.github/workflows/linux-old.yml b/.github/workflows/linux-old.yml index ecb5968f47..0aec21683c 100644 --- a/.github/workflows/linux-old.yml +++ b/.github/workflows/linux-old.yml @@ -89,8 +89,7 @@ jobs: run: | mkdir bld-cares cd bld-cares - cmake .. -DCMAKE_UNITY_BUILD=ON -DCURL_WERROR=ON -DBUILD_SHARED_LIBS=ON -DENABLE_ARES=ON -DCURL_ZSTD=ON -DCURL_USE_GSSAPI=ON -DCURL_USE_LIBSSH2=OFF \ - -DUSE_LIBSSH=ON '-DCMAKE_C_FLAGS=-I/usr/include -L/usr/lib -lssh' + cmake .. -DCMAKE_UNITY_BUILD=ON -DCURL_WERROR=ON -DBUILD_SHARED_LIBS=ON -DENABLE_ARES=ON -DCURL_ZSTD=ON -DCURL_USE_GSSAPI=ON -DCURL_USE_LIBSSH2=OFF -DCURL_USE_LIBSSH=ON - name: 'build' run: | diff --git a/CMakeLists.txt b/CMakeLists.txt index 8b864a8feb..580cc4357d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -994,11 +994,21 @@ 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) + find_package(libssh CONFIG QUIET) if(libssh_FOUND) message(STATUS "Found libssh ${libssh_VERSION}") - # Use imported target for include and library paths. - list(APPEND CURL_LIBS ssh) + else() + find_package(PkgConfig QUIET) + pkg_check_modules(LIBSSH "libssh") + if(LIBSSH_FOUND) + include_directories(${LIBSSH_INCLUDE_DIRS}) + endif() + endif() + if(libssh_FOUND OR LIBSSH_FOUND) + if(NOT DEFINED LIBSSH_LINK_LIBRARIES) + set(LIBSSH_LINK_LIBRARIES "ssh") # for find_package() with broken pkg-config (e.g. linux-old CI workflow) + endif() + list(APPEND CURL_LIBS ${LIBSSH_LINK_LIBRARIES}) list(APPEND LIBCURL_PC_REQUIRES_PRIVATE "libssh") set(USE_LIBSSH ON) endif()