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()