@@ -51,7 +51,7 @@ option(WITH_JPEG "Search for the libjpeg compression library to support addition
5151option (WITH_PNG "Search for the PNG compression library to support additional encodings" ON )
5252option (WITH_SDL "Search for the Simple Direct Media Layer library to build an example SDL vnc client" ON )
5353option (WITH_GTK "Search for the GTK library to build an example GTK vnc client" ON )
54- option (WITH_LIBSSH2 "Search for libssh2 to build an example ssh-tunneled client" ON )
54+ option (WITH_LIBSSHTUNNEL "Search for libsshtunnel to build an example ssh-tunneled client" ON )
5555option (WITH_THREADS "Search for a threading library to build with multithreading support" ON )
5656option (PREFER_WIN32THREADS "When searching for a threading library, prefer win32 threads if they are found" OFF )
5757option (WITH_GNUTLS "Search for the GnuTLS secure communications library to support TLS" ON )
@@ -145,9 +145,14 @@ if(WITH_GTK)
145145 find_package (GTK2 )
146146endif (WITH_GTK )
147147
148- if (WITH_LIBSSH2)
149- find_package (LibSSH2 )
150- endif (WITH_LIBSSH2 )
148+ if (WITH_LIBSSHTUNNEL)
149+ find_path (LIBSSHTUNNEL_INCLUDE_DIR libsshtunnel.h )
150+ find_library (LIBSSHTUNNEL_LIBRARY sshtunnel )
151+ if ("${LIBSSHTUNNEL_LIBRARY} " MATCHES ".*NOTFOUND.*" )
152+ # would otherwise contain -NOTFOUND, confusing target_link_libraries()
153+ set (LIBSSHTUNNEL_LIBRARY "" )
154+ endif ()
155+ endif (WITH_LIBSSHTUNNEL )
151156
152157if (WITH_THREADS)
153158 find_package (Threads )
@@ -628,17 +633,14 @@ if(GTK2_FOUND)
628633 )
629634endif (GTK2_FOUND )
630635
631- if (LIBSSH2_FOUND AND (CMAKE_USE_PTHREADS_INIT OR CMAKE_USE_WIN32_THREADS_INIT))
632- include_directories (${LIBSSH2_INCLUDE_DIR} )
636+ if (WITH_LIBSSHTUNNEL AND LIBSSHTUNNEL_LIBRARY AND LIBSSHTUNNEL_INCLUDE_DIR)
637+ message (STATUS "Building with libsshtunnel: ${LIBSSHTUNNEL_LIBRARY} and ${LIBSSHTUNNEL_INCLUDE_DIR} " )
638+ include_directories (${LIBSSHTUNNEL_INCLUDE_DIR} )
633639 set (LIBVNCCLIENT_EXAMPLES
634640 ${LIBVNCCLIENT_EXAMPLES}
635641 sshtunnel
636642 )
637643endif ()
638- # if not found, set lib var to empty, otherwise CMake complains
639- if (NOT LIBSSH2_FOUND)
640- set (LIBSSH2_LIBRARY "" )
641- endif ()
642644
643645if (FFMPEG_FOUND)
644646 include_directories (${FFMPEG_INCLUDE_DIRS} )
@@ -660,7 +662,7 @@ if(WITH_EXAMPLES)
660662 add_executable (client_examples_${e} ${LIBVNCCLIEXAMPLE_DIR} /${e}.c ${LIBVNCCLIEXAMPLE_DIR} /${${e}_EXTRA_SOURCES} )
661663 set_target_properties (client_examples_${e} PROPERTIES OUTPUT_NAME ${e} )
662664 set_target_properties (client_examples_${e} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} /examples/client )
663- target_link_libraries (client_examples_${e} vncclient ${CMAKE_THREAD_LIBS_INIT} ${SDL2_LIBRARY} ${GTK2_LIBRARIES} ${FFMPEG_LIBRARIES} ${LIBSSH2_LIBRARY } )
665+ target_link_libraries (client_examples_${e} vncclient ${CMAKE_THREAD_LIBS_INIT} ${SDL2_LIBRARY} ${GTK2_LIBRARIES} ${FFMPEG_LIBRARIES} ${LIBSSHTUNNEL_LIBRARY } )
664666 endforeach (e ${LIBVNCCLIENT_EXAMPLES} )
665667endif (WITH_EXAMPLES )
666668
0 commit comments