I install the GTK packages with:
vcpkg install gtk:x64-windows
I also set the environment variable CMAKE_TOOLCHAIN_FILE
to C:\vcpkg\scripts\buildsystems\vcpkg.cmake
, but find_package
can't find GTK. How do I find GTK in CMake?
Have you made sure to run .\vcpkg integrate install
via Powershell-Admin after you have built GTK? Are you building your project with the x64-windows
triplet defined (VCPKG_TARGET_TRIPLET)?
^ Once you do that, delete CMakeCache, and/or test regeneration to another folder and try Configuring again.
On the CMake side, check that your CMakeLists has find_package (GTK)
somewhere in there as well. You'll probably also have to define GTK_INCLUDE_DIR
and link GTK via target_link_libraries
on the CMake side.
CMAKE find_package along with vcpkg integration doesn't work as intended, at least with GTK4 libraries. I am able to fix by adding the dependencies manually something like below or probably create a CMAKE macro
include_directories(${PATH TO VCPKG INSTALLED}/gtk-4.0)
include_directories(${PATH TO VCPKG INSTALLED}/gtkmm-4.0) .. include rest of the used dependencies
The above should be able to compile the code, the following libraries should also be linked as below.
target_link_libraries(main "[VCPKG Intallation]/lib/sigc-3.0.lib") and all dependencies gtkmm-4.0.lib, gtk-4.lib .. as per your needs