Cmake 无法为我找到所需的包

Cmake cant find the required Packages for me

所以My Workspace Screenshot尝试了一段时间后,我无法让 Cmake 找到所需的包,即使我做了 vcpkg 中所示的所有操作

cmake_minimum_required(VERSION 3.0.0)
project(TEst VERSION 0.1.0)

include(CTest)
enable_testing()
set(CMAKE_TOOLCHAIN_FILE "N:/Vc-PKG/vcpkg/scripts/buildsystems/vcpkg.cmake")
find_package(glfw3 CONFIG REQUIRED)
target_link_libraries(TEst PRIVATE glfw)
add_executable(TEst main.cpp)

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

我的 Vcpkg 安装目录是 N:\Vc-PKG\vcpkg 我还在 vscode

中添加了这些行
    "C_Cpp.default.includePath": [
        "N:/Vc-PKG/vcpkg/installed/x64-windows/include",
        "N:/Vc-PKG/vcpkg/installed/x86-windows/include",
    ],
    "c-cpp-flylint.cppcheck.includePaths": [
        "N:\Vc-PKG\vcpkg\installed\x64-windows\include",
        "N:\Vc-PKG\vcpkg\installed\x86-windows\include",
    ],
    "cmake.generator": "MinGW Makefiles",

我得到的输出如下

[main] Configuring folder: Junks 
[proc] Executing command: N:\MSYS64\mingw64\bin\cmake.EXE --no-warn-unused-cli -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_C_COMPILER:FILEPATH=N:\MSYS64\mingw64\bin\x86_64-w64-mingw32-gcc.exe -DCMAKE_CXX_COMPILER:FILEPATH=N:\MSYS64\mingw64\bin\x86_64-w64-mingw32-g++.exe "-Hl:/Programming Projects/Vs Code/Junks" "-Bl:/Programming Projects/Vs Code/Junks/build" -G "MinGW Makefiles"
[cmake] Not searching for unused variables given on the command line.
[cmake] CMake Error at CMakeLists.txt:7 (find_package):
[cmake]   Could not find a package configuration file provided by "glfw3" with any of
[cmake]   the following names:
[cmake] 
[cmake]     glfw3Config.cmake
[cmake]     glfw3-config.cmake
[cmake] 
[cmake]   Add the installation prefix of "glfw3" to CMAKE_PREFIX_PATH or set
[cmake]   "glfw3_DIR" to a directory containing one of the above files.  If "glfw3"
[cmake]   provides a separate development package or SDK, be sure it has been
[cmake]   installed.
[cmake] 
[cmake] -- Configuring incomplete, errors occurred!
[cmake] See also "L:/Programming Projects/Vs Code/Junks/build/CMakeFiles/CMakeOutput.log".
[cmake] 

请提供任何帮助,如果我犯了错误,对不起,这是我第一次发布问题。

您不能在调用 project() 后设置 CMAKE_TOOLCHAIN_FILE。这是负责首先加载工具链文件的命令。在调用 project() 之前移动它或更好:在命令行或预设中设置它。

此外,除非您实际使用的是 CMake 3.0.0,否则不应将其设置为最低要求。 CMake 不向前兼容,因此如果不在最低版本上对其进行实际测试,您将无法知道它是否会在那个版本之前工作。