How to setup gtkmm development environment for Linux

Install gtkmm

You can compile it from source, but trust me, it’s not for human.

sudo apt install libgtkmm-3.0-dev

Use it directly with g++ 

I don’t really like this way, because our project grows.

g++ base.cc -o base `pkg-config gtkmm-3.0 --cflags --libs`

Use it with cmake

cmake_minimum_required(VERSION 3.0.0)
project(gtkmm_test VERSION 0.1.0)

find_package(PkgConfig)
pkg_check_modules(GTKMM gtkmm-3.0)
include_directories(${GTKMM_INCLUDE_DIRS})
link_directories(${GTKMM_LIBRARY_DIRS})
link_libraries(${GTKMM_LIBRARIES})

include(CTest)
enable_testing()

add_executable(gtkmm_test main.cpp)

set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)

Work with VSCode

You must allow cmake tools extension to be able to change your VScode settings, otherwise, no magic would appear within VSCode.

add a file called launch.json under .vscode folder so you can use F5 to launch your program:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            // Resolved by CMake Tools:
            "program": "${command:cmake.launchTargetPath}",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [
                {
                    // add the directory where our target was built to the PATHs
                    // it gets resolved by CMake Tools:
                    "name": "PATH",
                    "value": "$PATH:${command:cmake.launchTargetDirectory}"
                },
                {
                    "name": "OTHER_VALUE",
                    "value": "Something something"
                }
            ],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ]
        }
    ]
}

The author

yingshaoxo.blogspot.com
https://yingshaoxo.blogspot.com/2020/11/how-to-use-vcpkg-with-visual-studio.html