Support connecting to NETCONF clients via SSH

libnetconf doesn't have nice APIs for ssh connection, but allows users
to supply the connection by themselves. One way is to use libssh (which
libnetconf uses) and supply that. However, I found that using libssh to
implement an interactive CLI isn't very easy and I'd have to implement a
lot of functionality (like authentication) by myself, attempts were
made, but I was really only imitating the interface of OpenSSH.
Fortunately, libnetconf can also communicate over file descriptors, and
it is easy to get that from OpenSSH, so I fork it and use its
stdin/stdout. On top of that, OpenSSH is very clever and knows that I'm
using it like this, so it still allows entering passwords and accepting
host keys even though its stdin/stdout isn't a terminal.

Change-Id: I27816e038bed0a82a028c8e83c15455fd514c35e
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 39043a0..448b094 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -49,7 +49,7 @@
 option(WITH_DOCS "Create and install internal documentation (needs Doxygen)" ${DOXYGEN_FOUND})
 
 find_package(docopt REQUIRED)
-find_package(Boost REQUIRED)
+find_package(Boost REQUIRED COMPONENTS filesystem)
 find_library(REPLXX_LIBRARY NAMES replxx replxx-d REQUIRED)
 find_path(REPLXX_PATH replxx.hxx)
 if("${REPLXX_PATH}" STREQUAL REPLXX_PATH-NOTFOUND)
@@ -61,9 +61,6 @@
 pkg_check_modules(SYSREPO REQUIRED sysrepo-cpp>=1.4.79 IMPORTED_TARGET sysrepo)
 pkg_check_modules(LIBNETCONF2 REQUIRED libnetconf2>=1.1.32 IMPORTED_TARGET libnetconf2)
 
-# we don't need filename tracking, and we prefer to use header-only Boost
-add_definitions(-DBOOST_SPIRIT_X3_NO_FILESYSTEM)
-
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/)
 
 add_library(ast_values STATIC
@@ -165,6 +162,19 @@
     target_link_libraries(yang-cli stdc++fs)
 endif()
 
+add_executable(netconf-cli
+    src/cli.cpp
+    src/cli-netconf.cpp
+    )
+target_compile_definitions(netconf-cli PRIVATE NETCONF_CLI)
+
+# Boost.Process needs linking with threads, but doesn't have special CMake target which would do that for us. So, we
+# need to link manually. This will hopefully change in the future.
+# https://discourse.cmake.org/t/boost-process-target-doesnt-exist-for-thread-linking/2113
+set(THREADS_PREFER_PTHREAD_FLAG ON)
+find_package(Threads)
+target_link_libraries(netconf-cli netconfaccess Threads::Threads Boost::filesystem)
+cli_link_required(netconf-cli)
 
 
 include(CTest)
@@ -372,6 +382,7 @@
 endif()
 
 install(TARGETS
+    netconf-cli
     sysrepo-cli
     yang-cli
     RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/)