@@ -46,6 +46,7 @@ option(WITH_JPEG "Search for the libjpeg compression library to support addition
4646option (WITH_PNG "Search for the PNG compression library to support additional encodings" ON )
4747option (WITH_SDL "Search for the Simple Direct Media Layer library to build an example SDL vnc client" ON )
4848option (WITH_GTK "Search for the GTK library to build an example GTK vnc client" ON )
49+ option (WITH_LIBSSH2 "Search for libssh2 to build an example ssh-tunneled client" ON )
4950option (WITH_THREADS "Search for a threading library to build with multithreading support" ON )
5051option (PREFER_WIN32THREADS "When searching for a threading library, prefer win32 threads if they are found" OFF )
5152option (WITH_GNUTLS "Search for the GnuTLS secure communications library to support TLS" ON )
@@ -134,6 +135,10 @@ if(WITH_GTK)
134135 find_package (GTK2 )
135136endif (WITH_GTK )
136137
138+ if (WITH_LIBSSH2)
139+ find_package (LibSSH2 )
140+ endif (WITH_LIBSSH2 )
141+
137142if (WITH_THREADS)
138143 find_package (Threads )
139144endif (WITH_THREADS )
@@ -599,6 +604,17 @@ if(GTK2_FOUND)
599604 )
600605endif (GTK2_FOUND )
601606
607+ if (LIBSSH2_FOUND AND (CMAKE_USE_PTHREADS_INIT OR CMAKE_USE_WIN32_THREADS_INIT))
608+ include_directories (${LIBSSH2_INCLUDE_DIR} )
609+ set (LIBVNCCLIENT_EXAMPLES
610+ ${LIBVNCCLIENT_EXAMPLES}
611+ sshtunnel
612+ )
613+ endif ()
614+ # if not found, set lib var to empty, otherwise CMake complains
615+ if (NOT LIBSSH2_FOUND)
616+ set (LIBSSH2_LIBRARY "" )
617+ endif ()
602618
603619if (FFMPEG_FOUND)
604620 set (LIBVNCCLIENT_EXAMPLES
@@ -619,7 +635,7 @@ if(WITH_EXAMPLES)
619635 add_executable (client_examples_${e} ${LIBVNCCLIEXAMPLE_DIR} /${e}.c ${LIBVNCCLIEXAMPLE_DIR} /${${e}_EXTRA_SOURCES} )
620636 set_target_properties (client_examples_${e} PROPERTIES OUTPUT_NAME ${e} )
621637 set_target_properties (client_examples_${e} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} /client_examples )
622- target_link_libraries (client_examples_${e} vncclient ${CMAKE_THREAD_LIBS_INIT} ${SDL2_LIBRARY} ${GTK2_LIBRARIES} ${FFMPEG_LIBRARIES} )
638+ target_link_libraries (client_examples_${e} vncclient ${CMAKE_THREAD_LIBS_INIT} ${SDL2_LIBRARY} ${GTK2_LIBRARIES} ${FFMPEG_LIBRARIES} ${LIBSSH2_LIBRARY} )
623639 endforeach (e ${LIBVNCCLIENT_EXAMPLES} )
624640endif (WITH_EXAMPLES )
625641
0 commit comments