From 8871db498689d5b9f436d5233aec68ca3e328827 Mon Sep 17 00:00:00 2001
From: FuchtelJockel <alexander.reimelt@pm.me>
Date: Tue, 24 Aug 2021 12:15:54 +0200
Subject: [PATCH] build: fix includes, add glib and gio to CMakeLists.txt

First I added glib to cmake this fixed the glib.h not found error.
Then I got build errors from the missing GIO include as seen in the linked issue.
After adding the #include <gio/gio.h> the linker failed to find the gio library.
After adding the gio check to cmake all build issues were solved.

GitLab: #504
Change-Id: Iac537e10261f2e9dfa61029c4591e000851a378c
---
 CMakeLists.txt              | 17 +++++++++++++++--
 src/connectivitymonitor.cpp |  1 +
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index ec83cb502..6017c7b68 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -242,6 +242,16 @@ else()
 
     find_package(PkgConfig REQUIRED)
 
+    pkg_check_modules(GLIB REQUIRED glib-2.0)
+    if(GLIB_FOUND)
+        add_definitions(${GLIB_CFLAGS_OTHER})
+    endif()
+
+    pkg_check_modules(GIO REQUIRED gio-2.0)
+    if(GIO_FOUND)
+        add_definitions(${GIO_CFLAGS})
+    endif()
+
     pkg_check_modules(LIBNM libnm)
     if(LIBNM_FOUND)
         add_definitions(-DUSE_LIBNM)
@@ -294,7 +304,8 @@ else()
     include_directories(${LRC_SRC_PATH}
                         ${LIBNM_INCLUDE_DIRS}
                         ${LIBNOTIFY_INCLUDE_DIRS}
-                        ${LIBGDKPIXBUF_INCLUDE_DIRS})
+                        ${LIBGDKPIXBUF_INCLUDE_DIRS}
+                        ${GLIB_INCLUDE_DIRS})
 
     set(JAMI_DATA_PREFIX "${CMAKE_INSTALL_PREFIX}/share")
 
@@ -419,7 +430,9 @@ else()
                           ${X11}
                           ${LIBNM_LIBRARIES}
                           ${LIBNOTIFY_LIBRARIES}
-                          ${LIBGDKPIXBUF_LIBRARIES})
+                          ${LIBGDKPIXBUF_LIBRARIES}
+                          ${GLIB_LIBRARIES}
+                          ${GIO_LIBRARIES})
 
     # Installation rules
     install(TARGETS jami-qt
diff --git a/src/connectivitymonitor.cpp b/src/connectivitymonitor.cpp
index e70fffc66..d75b6bb4f 100644
--- a/src/connectivitymonitor.cpp
+++ b/src/connectivitymonitor.cpp
@@ -18,6 +18,7 @@
 
 #ifndef _WIN32
 #include <glib.h>
+#include <gio/gio.h>
 #ifdef USE_LIBNM
 #include <NetworkManager.h>
 #endif
-- 
GitLab