Skip to content

Commit

Permalink
build,examples: use libsshtunnel for ssh tunnel example
Browse files Browse the repository at this point in the history
...instead of libssh2 directly and lots of application logic.
  • Loading branch information
bk138 committed Nov 24, 2023
1 parent ce57832 commit 0a5b80c
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 416 deletions.
24 changes: 13 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ option(WITH_JPEG "Search for the libjpeg compression library to support addition
option(WITH_PNG "Search for the PNG compression library to support additional encodings" ON)
option(WITH_SDL "Search for the Simple Direct Media Layer library to build an example SDL vnc client" ON)
option(WITH_GTK "Search for the GTK library to build an example GTK vnc client" ON)
option(WITH_LIBSSH2 "Search for libssh2 to build an example ssh-tunneled client" ON)
option(WITH_LIBSSHTUNNEL "Search for libsshtunnel to build an example ssh-tunneled client" ON)
option(WITH_THREADS "Search for a threading library to build with multithreading support" ON)
option(PREFER_WIN32THREADS "When searching for a threading library, prefer win32 threads if they are found" OFF)
option(WITH_GNUTLS "Search for the GnuTLS secure communications library to support TLS" ON)
Expand Down Expand Up @@ -145,9 +145,14 @@ if(WITH_GTK)
find_package(GTK2)
endif(WITH_GTK)

if(WITH_LIBSSH2)
find_package(LibSSH2)
endif(WITH_LIBSSH2)
if(WITH_LIBSSHTUNNEL)
find_path(LIBSSHTUNNEL_INCLUDE_DIR libsshtunnel.h)
find_library(LIBSSHTUNNEL_LIBRARY sshtunnel)
if("${LIBSSHTUNNEL_LIBRARY}" MATCHES ".*NOTFOUND.*")
# would otherwise contain -NOTFOUND, confusing target_link_libraries()
set(LIBSSHTUNNEL_LIBRARY "")
endif()
endif(WITH_LIBSSHTUNNEL)

if(WITH_THREADS)
find_package(Threads)
Expand Down Expand Up @@ -628,17 +633,14 @@ if(GTK2_FOUND)
)
endif(GTK2_FOUND)

if(LIBSSH2_FOUND AND (CMAKE_USE_PTHREADS_INIT OR CMAKE_USE_WIN32_THREADS_INIT))
include_directories(${LIBSSH2_INCLUDE_DIR})
if(WITH_LIBSSHTUNNEL AND LIBSSHTUNNEL_LIBRARY AND LIBSSHTUNNEL_INCLUDE_DIR)
message(STATUS "Building with libsshtunnel: ${LIBSSHTUNNEL_LIBRARY} and ${LIBSSHTUNNEL_INCLUDE_DIR}")
include_directories(${LIBSSHTUNNEL_INCLUDE_DIR})
set(LIBVNCCLIENT_EXAMPLES
${LIBVNCCLIENT_EXAMPLES}
sshtunnel
)
endif()
# if not found, set lib var to empty, otherwise CMake complains
if(NOT LIBSSH2_FOUND)
set(LIBSSH2_LIBRARY "")
endif()

if(FFMPEG_FOUND)
include_directories(${FFMPEG_INCLUDE_DIRS})
Expand All @@ -660,7 +662,7 @@ if(WITH_EXAMPLES)
add_executable(client_examples_${e} ${LIBVNCCLIEXAMPLE_DIR}/${e}.c ${LIBVNCCLIEXAMPLE_DIR}/${${e}_EXTRA_SOURCES} )
set_target_properties(client_examples_${e} PROPERTIES OUTPUT_NAME ${e})
set_target_properties(client_examples_${e} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/examples/client)
target_link_libraries(client_examples_${e} vncclient ${CMAKE_THREAD_LIBS_INIT} ${SDL2_LIBRARY} ${GTK2_LIBRARIES} ${FFMPEG_LIBRARIES} ${LIBSSH2_LIBRARY})
target_link_libraries(client_examples_${e} vncclient ${CMAKE_THREAD_LIBS_INIT} ${SDL2_LIBRARY} ${GTK2_LIBRARIES} ${FFMPEG_LIBRARIES} ${LIBSSHTUNNEL_LIBRARY})
endforeach(e ${LIBVNCCLIENT_EXAMPLES})
endif(WITH_EXAMPLES)

Expand Down
43 changes: 0 additions & 43 deletions cmake/Modules/FindLibSSH2.cmake

This file was deleted.

Loading

0 comments on commit 0a5b80c

Please sign in to comment.