这个问题是关于VS Code的CMake Tools扩展。操作系统是Windows 10。
该扩展正确找到了GCC,我可以通过查看
我收到了以下输出:
该扩展正确找到了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"
}
}
我尝试通过VS Code的命令进行配置,但出现了错误:
[rollbar] Unhandled exception: Unhandled Promise rejection: configure Error: No usable generator found. {}
然后我将对应的设置添加到了本地设置文件中 .vscode/settings.json
。
{ "cmake.generator": "MSYS Makefiles" }
我收到了以下输出:
[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!
所以我扩展了我的本地设置。
{
"cmake.generator": "MSYS Makefiles",
"cmake.environment": {
"CMAKE_AR": "C:/msys64/usr/bin/ar.exe",
"CMAKE_MAKE_PROGRAM": "C:/msys64/usr/bin/make.exe"
}
}
得到了与之前相同的输出。我还尝试在CMakeLists.txt
中设置这些变量和作为系统环境变量。
正确的方法是什么?