From 26bc9bb629c49c0d5a8668a92c0c7b64626b65c7 Mon Sep 17 00:00:00 2001 From: Matthias Vogelgesang Date: Mon, 16 Oct 2017 09:28:30 +0200 Subject: Fix #7: use glib-unix.h only on UNIX-like OSes --- CMakeLists.txt | 4 ++++ config.h.in | 1 + meson.build | 1 + ucad.c | 9 ++++++++- 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 480c91c..45120e4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,6 +27,10 @@ pkg_check_variable(libuca plugindir) set(UCA_NET_DEFAULT_PORT 8989) +if (UNIX) + set(HAVE_UNIX 1) +endif () + configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h) diff --git a/config.h.in b/config.h.in index 43d9bb6..2b0b69c 100644 --- a/config.h.in +++ b/config.h.in @@ -1 +1,2 @@ +#cmakedefine HAVE_UNIX #cmakedefine UCA_NET_DEFAULT_PORT ${UCA_NET_DEFAULT_PORT} diff --git a/meson.build b/meson.build index 9c81a5d..8dcd4db 100644 --- a/meson.build +++ b/meson.build @@ -7,6 +7,7 @@ plugindir = uca_dep.get_pkgconfig_variable('plugindir') config = configuration_data() config.set('UCA_NET_DEFAULT_PORT', get_option('default_port')) +config.set('HAVE_UNIX', host_machine.system() != 'windows') configure_file( output: 'config.h', diff --git a/ucad.c b/ucad.c index 07e9157..8b2bd23 100644 --- a/ucad.c +++ b/ucad.c @@ -16,7 +16,6 @@ Franklin St, Fifth Floor, Boston, MA 02110, USA */ #include -#include #include #include #include @@ -25,6 +24,10 @@ #include "uca-net-protocol.h" #include "config.h" +#ifdef HAVE_UNIX +#include +#endif + static GMainLoop *loop; typedef void (*MessageHandler) (GSocketConnection *connection, UcaCamera *camera, gpointer message, GError **error); @@ -428,7 +431,11 @@ serve (UcaCamera *camera, guint16 port, GError **error) g_signal_connect (service, "run", G_CALLBACK (run_callback), camera); loop = g_main_loop_new (NULL, TRUE); + +#ifdef HAVE_UNIX g_unix_signal_add (SIGINT, (GSourceFunc) g_main_loop_quit, loop); +#endif + g_main_loop_run (loop); } -- cgit v1.2.3