client session BUILD make new libssh session options conditional

Fixes #133
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 598215f..c3299c3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,6 +2,7 @@
 project(libnetconf2 C)
 include(GNUInstallDirs)
 include(CheckFunctionExists)
+include(CheckCSourceCompiles)
 include(CheckIncludeFile)
 
 # include custom Modules
@@ -194,8 +195,20 @@
         target_link_libraries(netconf2 "-L${LIBSSH_LIBRARY_DIR}" -lssh -lssh_threads -lcrypt)
     else()
         target_link_libraries(netconf2 "-L${LIBSSH_LIBRARY_DIR}" -lssh -lcrypt)
+        set(CMAKE_REQUIRED_LIBRARIES "ssh;crypt")
     endif()
     include_directories(${LIBSSH_INCLUDE_DIRS})
+
+    set(LIBSSH_SESSION_OPTION_CHECK_CODE
+        "#include <libssh/libssh.h>
+        int main(void) {
+            ssh_session sess;
+            ssh_options_set(sess, SSH_OPTIONS_PUBLICKEY_ACCEPTED_TYPES, NULL);
+            return 0;
+        }"
+    )
+
+    check_c_source_compiles("${LIBSSH_SESSION_OPTION_CHECK_CODE}" HAVE_LIBSSH_OPTIONS_PUBLICKEY_ACCEPTED_TYPES)
 endif()
 
 # dependencies - libval
diff --git a/src/config.h.in b/src/config.h.in
index 909db63..96d33c5 100644
--- a/src/config.h.in
+++ b/src/config.h.in
@@ -48,6 +48,11 @@
 #cmakedefine HAVE_PTHREAD_MUTEX_TIMEDLOCK
 
 /*
+ * libssh support for this session option
+ */
+#cmakedefine HAVE_LIBSSH_OPTIONS_PUBLICKEY_ACCEPTED_TYPES
+
+/*
  * Location of installed basic YIN/YANG schemas
  */
 #define NC_SCHEMAS_DIR "@SCHEMAS_DIR@"
diff --git a/src/session_client_ssh.c b/src/session_client_ssh.c
index 4319517..b3fbcc5 100644
--- a/src/session_client_ssh.c
+++ b/src/session_client_ssh.c
@@ -1674,8 +1674,10 @@
     ssh_options_set(session->ti.libssh.session, SSH_OPTIONS_TIMEOUT, &timeout);
     ssh_options_set(session->ti.libssh.session, SSH_OPTIONS_HOSTKEYS, "ssh-ed25519,ecdsa-sha2-nistp256,"
             "ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-rsa,rsa-sha2-512,rsa-sha2-256,ssh-dss");
+#ifdef HAVE_LIBSSH_OPTIONS_PUBLICKEY_ACCEPTED_TYPES
     ssh_options_set(session->ti.libssh.session, SSH_OPTIONS_PUBLICKEY_ACCEPTED_TYPES, "ssh-ed25519,ecdsa-sha2-nistp256,"
             "ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-rsa,rsa-sha2-512,rsa-sha2-256,ssh-dss");
+#endif
 
     /* create and assign communication socket */
     sock = nc_sock_connect(host, port, -1, NULL, &ip_host);