libssh2 provides CMake targets: find_package(Libssh2 CONFIG REQUIRED) target_link_libraries(main PRIVATE $,Libssh2::libssh2_shared,Libssh2::libssh2_static>)