I'm attempting to set up an environment in which I can use gtkmm for C++ development. My CMakeLists.txt file looks like this:
cmake_minimum_required(VERSION 3.0.2)
project(program)
find_package(PkgConfig)
pkg_check_modules(GTKMM gtkmm-3.0)
link_directories(${GTKMM_LIBRARY_DIRS})
include_directories(include ${GTKMM_INCLUDE_DIRS})
file(GLOB SOURCES "*.cpp")
add_executable(program ${SOURCES})
target_link_libraries(program ${GTKMM_LIBRARIES})
Yet when I try to include the line include <gtkmm.h>
in main I am met with this error from CMake:
fatal error: 'gtkmm.h' file not found
#include <gtkmm.h>
I installed gtkmm with brew using the command brew install gtkmm
and brew install gtkmm3
to insure versions were not the issue. What can I do to get this working?
Be sure to install pkg-config (using brew).
Here is a CMakeLists.txt file that will work:
cmake_minimum_required(VERSION 3.16)
project(program LANGUAGES CXX)
find_package(PkgConfig)
pkg_check_modules(GTKMM gtkmm-3.0)
add_executable(program)
target_compile_features(program PRIVATE cxx_std_17)
target_sources(program PRIVATE main.cpp)
target_include_directories(program PRIVATE ${GTKMM_INCLUDE_DIRS})
target_link_directories(program PRIVATE ${GTKMM_LIBRARY_DIRS})
target_link_libraries(program PRIVATE ${GTKMM_LIBRARIES})