GTK项目的Makefile和CMake配置
作者:互联网
Makefile配置
CC := gcc
CFLAGS = -g -Wall `pkg-config --cflags gtk+-2.0`
LDFLAGS = `pkg-config --libs gtk+-2.0`
all: main
main: main.o
$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)
.PHONY: clean
clean:
$(RM) main *.o
CMake配置
CMakeLists.txt
# Copyright (c) 2019 Furzoom.com. All rights reserved.
# Author: mn@furzoom.com
cmake_minimum_required(VERSION 3.5)
project(gtk)
#
# GTK2_FOUND - Were all of your specified components found?
# GTK2_INCLUDE_DIRS - All include directories
# GTK2_LIBRARIES - All libraries
# GTK2_TARGETS - All imported targets
# GTK2_DEFINITIONS - Additional compiler flags
#
# GTK2_VERSION - The version of GTK2 found (x.y.z)
# GTK2_MAJOR_VERSION - The major version of GTK2
# GTK2_MINOR_VERSION - The minor version of GTK2
# GTK2_PATCH_VERSION - The patch version of GTK2
#
# Optional variables you can define prior to calling this module:
# GTK2_DEBUG - Enables verbose debugging of the module
# GTK2_ADDITIONAL_SUFFIXES - Allows defining additional directories to
# search for include files
#
find_package(GTK2 2.6 REQUIRED gtk)
if (GTK2_FOUND)
include_directories(${GTK2_INCLUDE_DIRS})
add_executable(main main.c)
target_link_libraries(main ${GTK2_LIBRARIES})
endif ()
标签:gtk,CMake,version,directories,GTK,Makefile,GTK2,VERSION,main 来源: https://blog.csdn.net/himayan46/article/details/94620289