I’m trying to setup Visual Studio 2022 with some libraries using vcpkg.
I have set my vcpkg.json to something like this, I’m trying to get it working with
manifest mode.
{
"name": "whatever",
"version-string": "whatever",
"dependencies": [
"fltk"
],
"builtin-baseline": "6f1ddd6b6878e7e66fcc35c65ba1d8feec2e01f8"
}
I have a CMakeLists.txt file like this:
cmake_minimum_required (VERSION 3.8)
set(CMAKE_TOOLCHAIN_FILE "mylocationfor\\vcpkg.cmake")
project ("CMakeProject1")
find_package(FLTK CONFIG REQUIRED)
add_executable (test main.cpp)
target_link_libraries(main PRIVATE fltk fltk_gl fltk_forms fltk_images)
After running cmake -B build/ -S .
.
I’m trying to roughly follow the documentation here.
https://learn.microsoft.com/en-us/vcpkg/consume/manifest-mode?tabs=cmake%2Cbuild-cmake
But when I do this. I have my main.cpp with some test code like this.
#include <iostream>
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Box.H>
int main(int argc, char** argv) {
Fl_Window* window = new Fl_Window(340, 180);
Fl_Box* box = new Fl_Box(20, 40, 300, 100, "Hello, World!");
box->box(FL_UP_BOX);
box->labelfont(FL_BOLD + FL_ITALIC);
box->labelsize(36);
box->labeltype(FL_SHADOW_LABEL);
window->end();
window->show(argc, argv);
return Fl::run();
}
I can generate but can’t build this, as it says it can’t find the FL headers.
I understand I can try to set the headers manually in project properties but even then it doesn’t seem to be linking the library properly.
A vcpkg list
says no packages are installed, I can also run vcpkg install instead of through cmake then vcpkg list
shows me stuff. But obviously CMake places the
“vcpkg_installed” folder within my root/build/ folder. And I’ve checked that the headers and libraries are there.
How can I get the IDE to actually find the headers and link properly after configuring and then trying to build? Isn’t this meant to be automatically found when I configure and build. Also I’m not sure if manifest mode is enabled (when doing the cmake configure to get dependencies) as I can’t seem to find the location on VS2022, everything I try follow has VS2019 and they set it through Project Properties -> vcpkg and enable it there but I can’t find anything of the sort on 2022.