From 5b0a9dbd28c58feda396e06693379ad1f21e28d2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micka=C3=ABl=20Turnel?=
 <mickael.turnel@belledonne-communications.com>
Date: Mon, 17 Jul 2023 11:40:16 +0200
Subject: [PATCH] Fix soci not loading libraries when tester is not installed

---
 config.h.cmake              | 2 ++
 tester/liblinphone_tester.c | 4 ++++
 tester/liblinphone_tester.h | 3 +++
 tester/tester.cpp           | 7 +++++++
 4 files changed, 16 insertions(+)

diff --git a/config.h.cmake b/config.h.cmake
index 8eea083695..ecd25d19b2 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -51,6 +51,8 @@
 #define MEDIASTREAMER2_LOCAL_PLUGINS_LOCATION "${CMAKE_BINARY_DIR}/lib/mediastreamer2/plugins"
 #define LIBLINPHONE_LOCAL_PLUGINS_LOCATION "${CMAKE_BINARY_DIR}/lib/liblinphone/plugins"
 
+#define SOCI_LOCAL_PLUGINS_LOCATION "${CMAKE_BINARY_DIR}/lib"
+
 #cmakedefine HAVE_ZLIB 1
 #cmakedefine HAVE_CU_GET_SUITE 1
 #cmakedefine HAVE_CU_CURSES 1
diff --git a/tester/liblinphone_tester.c b/tester/liblinphone_tester.c
index 1064261410..368d6e0604 100644
--- a/tester/liblinphone_tester.c
+++ b/tester/liblinphone_tester.c
@@ -132,6 +132,10 @@ static int liblinphone_tester_start(int argc, char *argv[]) {
 
 		linphone_factory_set_msplugins_dir(linphone_factory_get(), MEDIASTREAMER2_LOCAL_PLUGINS_LOCATION);
 		linphone_factory_set_liblinphone_plugins_dir(linphone_factory_get(), LIBLINPHONE_LOCAL_PLUGINS_LOCATION);
+
+#ifdef HAVE_SOCI
+		liblinphone_tester_add_soci_search_path(SOCI_LOCAL_PLUGINS_LOCATION);
+#endif
 	}
 #endif
 
diff --git a/tester/liblinphone_tester.h b/tester/liblinphone_tester.h
index eb8428e04d..159e7af538 100644
--- a/tester/liblinphone_tester.h
+++ b/tester/liblinphone_tester.h
@@ -1029,6 +1029,9 @@ bctbx_list_t *liblinphone_tester_remove_v6_addr(bctbx_list_t *l);
 
 bool_t liblinphone_tester_is_executable_installed(const char *executable, const char *resource);
 void liblinphone_tester_add_grammar_loader_path(const char *path);
+#ifdef HAVE_SOCI
+void liblinphone_tester_add_soci_search_path(const char *path);
+#endif
 
 #ifdef __cplusplus
 };
diff --git a/tester/tester.cpp b/tester/tester.cpp
index 2df0ca3bff..00ffc813d3 100644
--- a/tester/tester.cpp
+++ b/tester/tester.cpp
@@ -25,6 +25,7 @@
 #include <belr/grammarbuilder.h>
 
 #ifdef HAVE_SOCI
+#include <soci/backend-loader.h>
 #include <soci/soci.h>
 #endif
 
@@ -84,3 +85,9 @@ bool_t liblinphone_tester_is_executable_installed(const char *executable, const
 void liblinphone_tester_add_grammar_loader_path(const char *path) {
 	belr::GrammarLoader::get().addPath(std::string(path));
 }
+
+#ifdef HAVE_SOCI
+void liblinphone_tester_add_soci_search_path(const char *path) {
+	soci::dynamic_backends::search_paths().emplace_back(path);
+}
+#endif
-- 
GitLab