我有以下简单的C程序,它通知我在Xfce的哪个工作区。我可以成功编译它并将其与命令一起使用
gcc -O2 -DWNCK_I_KNOW_THIS_IS_UNSTABLE -o wsnd
pkg-config --cflags --libs libnotify --libs libwnck-1.0
wsn.c
但是我如何设置Cmake配置文件,以便clion也可以编译它?如何在Cmake中使用pkg-config?
#include <libnotify/notify.h>
#include <libwnck-3.0/libwnck/libwnck.h>
#define N_SUMMARY "Workspace Changed"
#define N_ICON "dialog-information"
#define N_APPNAME "workspace switch notifier"
#define N_TIMEOUT 2000 /*2000ms = 2s */
static NotifyNotification * m_notification = NULL;
static void
on_active_workspace_changed (WnckScreen *screen,
WnckWorkspace *space,
gpointer data)
{
WnckWorkspace * active_workspace = wnck_screen_get_active_workspace(screen);
const char * w_name = wnck_workspace_get_name (active_workspace);
notify_notification_update(m_notification, N_SUMMARY, w_name, N_ICON);
notify_notification_show(m_notification, NULL);
}
int main(int argc, char ** argv)
{
GMainLoop *loop;
WnckScreen *screen;
if (notify_init(N_APPNAME))
m_notification = notify_notification_new(N_SUMMARY, "" , N_ICON);
else
fprintf(stderr, "Failed to init notifications\n");
notify_notification_set_timeout(m_notification, N_TIMEOUT);
gdk_init (&argc, &argv);
loop = g_main_loop_new (NULL, FALSE);
screen = wnck_screen_get_default();
g_signal_connect (screen, "active-workspace-changed",
G_CALLBACK (on_active_workspace_changed), NULL);
g_main_loop_run (loop);
g_main_loop_unref (loop);
return 0;
}