这是 Makefile 中的 CFLAGS。
CFLAGS = -I/usr/include/libglade-2.0 -I/usr/include/gsl `pkg-config --cflags --libs gtk+-2.0` -lglade-2.0 -lglut -I/usr/local/include/dc1394 -ldc1394
Run Code Online (Sandbox Code Playgroud)
我想使用 CMAKE 而不是 Makefile。这部分是我写的CMakeLists.txt文件。
find_package(PkgConfig REQUIRED)
pkg_check_modules(GTK REQUIRED "gtk+-2.0")
# Add the path to its header files to the compiler command line
include_directories(${GTK_INCLUDE_DIRS})
link_directories(${GTK_LIBRARY_DIRS})
# Add any compiler flags it requires
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GTK_CFLAGS}")
# Add the makefile target for your executable and link in the GTK library
target_link_libraries(${CMAKE_PROJECT_NAME} ${GTK_LIBRARIES})
# gtk and glade
find_package(GTK2 2.10 REQUIRED gtk glade)
if(GTK2_FOUND)
include_directories(${GTK2_INCLUDE_DIRS})
target_link_libraries(${CMAKE_PROJECT_NAME} ${GTK2_LIBRARIES}) …Run Code Online (Sandbox Code Playgroud)