0

I am currently learning C++ along CMake and I am trying to build a simple project to exercise. For that I want to use GTK, but I can't figure out how to add a library using CMake from the documentation. I installed libgtkmm-3.0-dev and I created the following CMakeLists.txt in the root of my project:

cmake_minimum_required(VERSION 3.0.0)
project(GTK-Chess VERSION 0.1.0)

find_library(GTKMM gtkmm-3.0)

add_executable(GTK-Chess src/main.cpp)

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

Can anyone help me add this library and maybe explain the Cmake functions used so I can better understand the process? Thank you very much!

Tsyvarev
  • 60,011
  • 17
  • 110
  • 153
Adrian Pascu
  • 949
  • 5
  • 20
  • 48
  • Aside the duplication question, there is also [official documentation](https://wiki.gnome.org/Projects/gtkmm/UsingCMake) about using GTKmm in CMake. – Tsyvarev Apr 08 '20 at 09:39
  • 2
    It is unfortunate that both resources you linked to use older methods. In modern CMake, you can simply use the `FindPkgConfig` module to create an imported target that you can `target_link_libraries` to. See [this answer](https://stackoverflow.com/a/57224542/1548468) – Botje Apr 08 '20 at 09:49
  • 3
    @Botje: I have added an appropriate comment to the [answer](https://stackoverflow.com/a/45638445/3440745) on the duplication question. – Tsyvarev Apr 08 '20 at 11:07

0 Answers0