text CMake和GTK + 3

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了text CMake和GTK + 3相关的知识,希望对你有一定的参考价值。

#include <gtk/gtk.h>

static void
activate(GtkApplication *app,
    gpointer user_data) {
    GtkWidget *window;

    window = gtk_application_window_new(app);
    gtk_window_set_title(GTK_WINDOW(window), "Hello GNOME");
    gtk_widget_show_all(window);
}

int
main(int argc, char **argv) {
    GtkApplication *app;
    int status;

    app = gtk_application_new("org.gtk.example",
        G_APPLICATION_FLAGS_NONE);
    g_signal_connect(app, "activate",
        G_CALLBACK(activate), NULL);
    status = g_application_run(G_APPLICATION(app), argc, argv);
    g_object_unref(app);
    return (status);
}
# Set the name and the supported language of the project
PROJECT(hello-world C)
# Set the minimum version of cmake required to build this project
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)

# Use the package PkgConfig to detect GTK+ headers/library files
FIND_PACKAGE(PkgConfig REQUIRED)
PKG_CHECK_MODULES(GTK3 REQUIRED gtk+-3.0)

# Setup CMake to use GTK+, tell the compiler where to look for headers
# and to the linker where to look for libraries
INCLUDE_DIRECTORIES(${GTK3_INCLUDE_DIRS})
LINK_DIRECTORIES(${GTK3_LIBRARY_DIRS})

# Add other flags to the compiler
ADD_DEFINITIONS(${GTK3_CFLAGS_OTHER})

# Add an executable compiled from hello.c
ADD_EXECUTABLE(hello main.c)

# Link the target to the GTK+ libraries
TARGET_LINK_LIBRARIES(hello ${GTK3_LIBRARIES})

以上是关于text CMake和GTK + 3的主要内容,如果未能解决你的问题,请参考以下文章

Mac上使用clion基于cmake 开发gtk

用cmake构建gtk程序

在 Cmake 中包含 pkg-config --cflags --libs gtk+-2.0

在 Python-GTK3 中设置条目文本的 set_text 在哪里?

GTKmm 的 CMake 错误 - 找不到包 'gtkmm-3.0'

GTK 3+ GtkProgressBar 使用