Neo*_*nit 7 cmake msys2 visual-studio-code
这个问题是关于VS Code的CMake 工具扩展。操作系统为Windows 10。
该扩展正确地找到了 GCC,我可以通过查看%LocalAppData%/CMakeTools/cmake-tools-kits.json.
{
"name": "GCC 10.3.0 x86_64-w64-mingw32",
"compilers": {
"C": "C:\\msys64\\mingw64\\bin\\x86_64-w64-mingw32-gcc.exe",
"CXX": "C:\\msys64\\mingw64\\bin\\x86_64-w64-mingw32-g++.exe"
}
}
Run Code Online (Sandbox Code Playgroud)
我尝试通过相应的 VS Code 命令进行配置,但出现错误:
[rollbar] Unhandled exception: Unhandled Promise rejection: configure Error: No usable generator found. {}
Run Code Online (Sandbox Code Playgroud)
然后我将相应的设置添加到我的本地设置中.vscode/settings.json。
[rollbar] Unhandled exception: Unhandled Promise rejection: configure Error: No usable generator found. {}
Run Code Online (Sandbox Code Playgroud)
我得到以下输出:
[proc] Executing command: "C:/Program Files/CMake/bin/cmake.exe" --no-warn-unused-cli -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_C_COMPILER:FILEPATH=C:\msys64\mingw64\bin\x86_64-w64-mingw32-gcc.exe -DCMAKE_CXX_COMPILER:FILEPATH=C:\msys64\mingw64\bin\x86_64-w64-mingw32-g++.exe -H<path to project root> -B<path to build directory> -G "MSYS Makefiles"
[cmake] Not searching for unused variables given on the command line.
[cmake] CMake Error: CMake was unable to find a build program corresponding to "MSYS Makefiles". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.
[cmake] CMake Error: CMake was unable to find a build program corresponding to "MSYS Makefiles". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.
[cmake] CMake Error: CMAKE_AR was not found, please set to archive program.
[cmake] -- Configuring incomplete, errors occurred!
Run Code Online (Sandbox Code Playgroud)
所以我扩展了我的本地设置。
{ "cmake.generator": "MSYS Makefiles" }
Run Code Online (Sandbox Code Playgroud)
得到与之前相同的输出。我还尝试将这些变量设置为CMakeLists.txt系统环境变量。
执行此操作的正确方法是什么?
小智 2
我知道这是一个老请求,但我最近一直受到这个问题的困扰。
我发现的技巧(使用 Windows 上当前版本的 MSYS2)是安装 mingw64 的 cmake 版本。
使用命令:
pacman -S mingw-w64-x86_64-cmake
Run Code Online (Sandbox Code Playgroud)
注意:这假设您的路径中定义了 pacman,否则您需要为 pacman 添加路径前缀。
然后安装忍者:
pacman -S ninja
Run Code Online (Sandbox Code Playgroud)
您不需要在 VSCode 设置中定义配置,它应该可以正常工作。
| 归档时间: |
|
| 查看次数: |
11901 次 |
| 最近记录: |