问题
I have copied a sample project from GTK
#include <gtkmm.h>
int main(int argc, char *argv[])
{
auto app = Gtk::Application::create(argc, argv, "org.gtkmm.examples.base");
Gtk::Window window;
window.set_default_size(200, 200);
return app->run(window);
}
And when compiling directly from terminal it works just fine:
g++ main.cpp -o simple `pkg-config gtkmm-3.0 --cflags --libs`
But when I try compilation using Clion it says
fatal error: gtkmm.h: No such file or directory
#include <gtkmm.h>
My CMakeLists.txt looks like this:
cmake_minimum_required(VERSION 3.8)
project(songbook)
set(CMAKE_CXX_STANDARD 17)
find_package(PkgConfig REQUIRED)
pkg_check_modules(GTK3 REQUIRED gtk+-3.0)
include_directories(${GTK3_INCLUDE_DIRS})
link_directories(${GTK3_LIBRARY_DIRS})
add_definitions(${GTK3_CFLAGS_OTHER})
set(SOURCE_FILES main.cpp)
add_executable(songbook ${SOURCE_FILES})
target_link_libraries(songbook ${GTK3_LIBRARIES})
What am I doing wrong?
回答1:
Solved thanks to https://github.com/DreaminginCodeZH/gtkmmproject! Final CMakeLists.txt:
cmake_minimum_required(VERSION 3.8)
project(songbook)
set(CMAKE_CXX_STANDARD 17)
find_package(PkgConfig)
pkg_check_modules(GTKMM gtkmm-3.0)
include_directories(${GTKMM_INCLUDE_DIRS})
link_directories(${GTKMM_LIBRARY_DIRS})
set(SOURCE_FILES main.cpp MainWindow.cpp MainWindow.h)
add_executable(songbook ${SOURCE_FILES})
target_link_libraries(${CMAKE_PROJECT_NAME} ${GTKMM_LIBRARIES})
来源:https://stackoverflow.com/questions/45637558/how-to-configure-clion-to-compile-gtkmm-project