# Have a problems setting GTK in CMake correctly.

**URL:** https://discourse.cmake.org/t/have-a-problems-setting-gtk-in-cmake-correctly/10570
**Category:** Code
**Created:** [April 4, 2024, 7:03pm UTC](https://discourse.cmake.org/t/have-a-problems-setting-gtk-in-cmake-correctly/10570 "2024-04-04T19:03:16Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![WaltOnline](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/w/9dc877/32.png) [@WaltOnline](https://discourse.cmake.org/u/WaltOnline)
#### Post date: [April 4, 2024, 7:03pm UTC](https://discourse.cmake.org/t/have-a-problems-setting-gtk-in-cmake-correctly/10570/1 "2024-04-04T19:03:17Z")

</div>

Hello!

1. I cloned vcpkg from git repo it created “vcpkg” directory in E:\
2. I launched a bootstrap-vcpkg.bat and it downloaded vcpkg.exe

> PS E:\vcpkg\> .\bootstrap-vcpkg.bat

```auto
Downloading https://github.com/microsoft/vcpkg-tool/releases/download/2024-03-14/vcpkg.exe -> E:\vcpkg\vcpkg.exe... done.
Validating signature... done.

vcpkg package management program version 2024-03-14-7d353e869753e5609a1f1a057df3db8fd356e49d

See LICENSE.txt for license information.

```

1. then I integrated vcpkg

> PS E:\vcpkg\> .\vcpkg.exe integrate install

```auto
CMake projects should use: "-DCMAKE_TOOLCHAIN_FILE=E:/vcpkg/scripts/buildsystems/vcpkg.cmake"

All MSBuild C++ projects can now #include any installed libraries. Linking will be handled automatically. Installing new libraries will make them instantly available.

```

then I installed gtk package:

> PS E:\vcpkg\> .\vcpkg.exe install gtk

it was 1 hour process and it went without errors, it created “x64-windows” directory in  
“E:\vcpkg\installed”

After that I created CMake project in Visual Studio 2022 17.9.4 (CMake is 3.29 version)

I added that line to CMakePresets.json

> “CMAKE\_TOOLCHAIN\_FILE”: “$env{VCPKG\_ROOT}/scripts/buildsystems/vcpkg.cmake”

at the bottom of a cacheVariables:

> ```
> "cacheVariables": {
> "CMAKE_C_COMPILER": "cl.exe",
> "CMAKE_CXX_COMPILER": "cl.exe",
> "CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
> }, 
> 
> ```

I set user env variable  
name: VCPKG\_ROOT  
value: E:\vcpkg

I checked that file “vcpkg.cmake” is there according to that above path.

this apparently doesn’t work

> cmake\_minimum\_required (VERSION 3.8)  
> project(GTKTest1)
> 
> find\_package(GTK REQUIRED)
> 
> add\_executable (Main “Main.cpp” )  
> target\_link\_libraries(Main PRIVATE GTK)

What else I need to do to make CMake find all GTK package, what I’m doing wrong ?

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [April 11, 2024, 4:41pm UTC](https://discourse.cmake.org/t/have-a-problems-setting-gtk-in-cmake-correctly/10570/2 "2024-04-11T16:41:52Z")

</div>

This feels like more of a question for `vcpkg` than CMake itself. I’m not sure that all of the steps to use `vcpkg` have been followed here, but that’s just a hunch.
