From 64df5e21c011d7b60945dc05b6f64a56f19cd566 Mon Sep 17 00:00:00 2001 From: Ryan Blue Date: Sat, 14 Sep 2024 17:47:12 -0400 Subject: [PATCH] [build] cmake: Fix libssh search on windows (#7081) This uses the package config files provided by libssh rather than the module file. --- CMakeLists.txt | 2 +- cmake/modules/FindLIBSSH.cmake | 143 ------------------------- datalogtool/CMakeLists.txt | 3 +- roborioteamnumbersetter/CMakeLists.txt | 3 +- vcpkg.json | 3 +- 5 files changed, 5 insertions(+), 149 deletions(-) delete mode 100644 cmake/modules/FindLIBSSH.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 6c4b56fd2e..13c85a831e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -129,7 +129,7 @@ else() find_package(Java REQUIRED COMPONENTS Runtime) endif() -find_package(LIBSSH 0.7.1) +find_package(LIBSSH CONFIG 0.7.1) set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON) if(WITH_PROTOBUF) diff --git a/cmake/modules/FindLIBSSH.cmake b/cmake/modules/FindLIBSSH.cmake deleted file mode 100644 index 6578aa9976..0000000000 --- a/cmake/modules/FindLIBSSH.cmake +++ /dev/null @@ -1,143 +0,0 @@ -# - Try to find LibSSH -# Once done this will define -# -# LIBSSH_FOUND - system has LibSSH -# LIBSSH_INCLUDE_DIRS - the LibSSH include directory -# LIBSSH_LIBRARIES - link these to use LibSSH -# LIBSSH_VERSION - -# -# Author Michal Vasko -# Copyright (c) 2020 CESNET, z.s.p.o. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. The name of the author may not be used to endorse or promote products -# derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -include(FindPackageHandleStandardArgs) - -if(LIBSSH_LIBRARIES AND LIBSSH_INCLUDE_DIRS) - # in cache already - set(LIBSSH_FOUND TRUE) -else() - find_path( - LIBSSH_INCLUDE_DIR - NAMES libssh/libssh.h - PATHS - /usr/include - /usr/local/include - /opt/local/include - /sw/include - ${CMAKE_INCLUDE_PATH} - ${CMAKE_INSTALL_PREFIX}/include - ) - - find_library( - LIBSSH_LIBRARY - NAMES ssh.so libssh.so libssh.dylib - PATHS - /usr/lib - /usr/local/lib - /opt/local/lib - /sw/lib - ${CMAKE_LIBRARY_PATH} - ${CMAKE_INSTALL_PREFIX}/lib - ) - - if(LIBSSH_INCLUDE_DIR AND LIBSSH_LIBRARY) - # learn libssh version - if(EXISTS ${LIBSSH_INCLUDE_DIR}/libssh/libssh_version.h) - set(LIBSSH_HEADER_PATH ${LIBSSH_INCLUDE_DIR}/libssh/libssh_version.h) - else() - set(LIBSSH_HEADER_PATH ${LIBSSH_INCLUDE_DIR}/libssh/libssh.h) - endif() - file( - STRINGS - ${LIBSSH_HEADER_PATH} - LIBSSH_VERSION_MAJOR - REGEX "#define[ ]+LIBSSH_VERSION_MAJOR[ ]+[0-9]+" - ) - if(NOT LIBSSH_VERSION_MAJOR) - message( - STATUS - "LIBSSH_VERSION_MAJOR not found, assuming libssh is too old and cannot be used!" - ) - set(LIBSSH_INCLUDE_DIR "LIBSSH_INCLUDE_DIR-NOTFOUND") - set(LIBSSH_LIBRARY "LIBSSH_LIBRARY-NOTFOUND") - else() - string(REGEX MATCH "[0-9]+" LIBSSH_VERSION_MAJOR ${LIBSSH_VERSION_MAJOR}) - file( - STRINGS - ${LIBSSH_HEADER_PATH} - LIBSSH_VERSION_MINOR - REGEX "#define[ ]+LIBSSH_VERSION_MINOR[ ]+[0-9]+" - ) - string(REGEX MATCH "[0-9]+" LIBSSH_VERSION_MINOR ${LIBSSH_VERSION_MINOR}) - file( - STRINGS - ${LIBSSH_HEADER_PATH} - LIBSSH_VERSION_PATCH - REGEX "#define[ ]+LIBSSH_VERSION_MICRO[ ]+[0-9]+" - ) - string(REGEX MATCH "[0-9]+" LIBSSH_VERSION_PATCH ${LIBSSH_VERSION_PATCH}) - - set(LIBSSH_VERSION - ${LIBSSH_VERSION_MAJOR}.${LIBSSH_VERSION_MINOR}.${LIBSSH_VERSION_PATCH} - ) - - if(LIBSSH_VERSION VERSION_LESS 0.8.0) - # libssh_threads also needs to be linked for these versions - string( - REPLACE - "libssh.so" - "libssh_threads.so" - LIBSSH_THREADS_LIBRARY - ${LIBSSH_LIBRARY} - ) - string( - REPLACE - "libssh.dylib" - "libssh_threads.dylib" - LIBSSH_THREADS_LIBRARY - ${LIBSSH_THREADS_LIBRARY} - ) - string( - REPLACE - "ssh.so" - "ssh_threads.so" - LIBSSH_THREADS_LIBRARY - ${LIBSSH_THREADS_LIBRARY} - ) - endif() - endif() - endif() - - set(LIBSSH_INCLUDE_DIRS ${LIBSSH_INCLUDE_DIR}) - set(LIBSSH_LIBRARIES ${LIBSSH_LIBRARY} ${LIBSSH_THREADS_LIBRARY}) - mark_as_advanced(LIBSSH_INCLUDE_DIRS LIBSSH_LIBRARIES) - - find_package_handle_standard_args( - LIBSSH - FOUND_VAR LIBSSH_FOUND - REQUIRED_VARS LIBSSH_INCLUDE_DIRS LIBSSH_LIBRARIES - VERSION_VAR LIBSSH_VERSION - ) -endif() diff --git a/datalogtool/CMakeLists.txt b/datalogtool/CMakeLists.txt index 00b760e14a..ba9475d2eb 100644 --- a/datalogtool/CMakeLists.txt +++ b/datalogtool/CMakeLists.txt @@ -25,8 +25,7 @@ add_executable( ${APP_ICON_MACOSX} ) wpilib_link_macos_gui(datalogtool) -target_link_libraries(datalogtool libglass ${LIBSSH_LIBRARIES}) -target_include_directories(datalogtool SYSTEM PRIVATE ${LIBSSH_INCLUDE_DIRS}) +target_link_libraries(datalogtool libglass ssh) if(WIN32) set_target_properties(datalogtool PROPERTIES WIN32_EXECUTABLE YES) diff --git a/roborioteamnumbersetter/CMakeLists.txt b/roborioteamnumbersetter/CMakeLists.txt index 7a43baaed9..c249c7c8c2 100644 --- a/roborioteamnumbersetter/CMakeLists.txt +++ b/roborioteamnumbersetter/CMakeLists.txt @@ -25,8 +25,7 @@ add_executable( ${APP_ICON_MACOSX} ) wpilib_link_macos_gui(roborioteamnumbersetter) -target_link_libraries(roborioteamnumbersetter libglass wpinet ${LIBSSH_LIBRARIES}) -target_include_directories(roborioteamnumbersetter SYSTEM PRIVATE ${LIBSSH_INCLUDE_DIRS}) +target_link_libraries(roborioteamnumbersetter libglass wpinet ssh) if(WIN32) set_target_properties(roborioteamnumbersetter PROPERTIES WIN32_EXECUTABLE YES) diff --git a/vcpkg.json b/vcpkg.json index fc499d086b..ea1d2a9b5b 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -5,7 +5,8 @@ "opencv", "fmt", "libuv", - "protobuf" + "protobuf", + "libssh" ], "builtin-baseline": "37c3e63a1306562f7f59c4c3c8892ddd50fdf992" }