I am trying to use vcpkg with cmake but I got an error(this error is in the problems tab of my vscode project):
[{
"resource": "/c:/Users/MyPC/Documents/Opengl/CMakeLists.txt",
"owner": "cmake-configure-diags",
"severity": 8,
"message": "CMake Error at CMakeLists.txt:5 (find_package):By not providing "Findglfw3.cmake" in CMAKE_MODULE_PATH this project hasnasked CMake to find a package configuration file provided by "glfw3", butnCMake did not find one.nnCould not find a package configuration file provided by "glfw3" with any ofnthe following names:nn glfw3Config.cmaken glfw3-config.cmakennAdd the installation prefix of "glfw3" to CMAKE_PREFIX_PATH or setn"glfw3_DIR" to a directory containing one of the above files. If "glfw3"nprovides a separate development package or SDK, be sure it has beenninstalled.",
"source": "CMake (find_package)",
"startLineNumber": 5,
"startColumn": 1,
"endLineNumber": 5,
"endColumn": 10000
}]
here is my cpp code:
#include <GLFW/glfw3.h>
int main(){
GLFWwindow* window;
if (!glfwInit()){
return -1;
}
window = glfwCreateWindow(400, 400, "my name", NULL, NULL);
while(!glfwWindowShouldClose(window)){
glfwPollEvents();
}
return 0;
}
here is my cmake code:
cmake_minimum_required(VERSION 3.30.3)
project(cpp)
add_executable(cpp main.cpp)
set(CMAKE_TOOLCHAIN_FILE "-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake")
find_package(glfw3 REQUIRED)
target_link_libraries(cpp PRIVATE glfw3)
and also the error of main.cpp included no such file or directory.
I expected it to create a window. I tried to reinstall compiler, tried to install visual studio build tools and it can install packages but when I set the CMAKE_TOOLCHAIN_FILE to what the vcpkg integrate install told me to do, it didn’t work.