Cmake找不到我需要的软件包



所以我的工作空间截图在尝试了一段时间后,我不能得到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-PKGvcpkg我还在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:MSYS64mingw64bincmake.EXE --no-warn-unused-cli -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_C_COMPILER:FILEPATH=N:MSYS64mingw64binx86_64-w64-mingw32-gcc.exe -DCMAKE_CXX_COMPILER:FILEPATH=N:MSYS64mingw64binx86_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不是向前兼容的,所以没有在最小版本上实际测试它,你无法知道它是否能工作那么远。

最新更新