diff options
-rw-r--r-- | CMakeLists.txt | 4 | ||||
-rw-r--r-- | config.h.in | 1 | ||||
-rw-r--r-- | meson.build | 1 | ||||
-rw-r--r-- | ucad.c | 9 |
4 files changed, 14 insertions, 1 deletions
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', @@ -16,7 +16,6 @@ Franklin St, Fifth Floor, Boston, MA 02110, USA */ #include <glib-object.h> -#include <glib-unix.h> #include <gio/gio.h> #include <string.h> #include <signal.h> @@ -25,6 +24,10 @@ #include "uca-net-protocol.h" #include "config.h" +#ifdef HAVE_UNIX +#include <glib-unix.h> +#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); } |