How to configure VS Code's CMake Tools Extension for GCC and MSYS Makefiles on Windows?

Viewed 3060

This question is about the CMake Tools extension for VS Code. The operation system is Windows 10.

The extension correctly found GCC, which I can verify by having a look at the %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"
  }
}

I tried to configure through the respective VS Code command and got an error:

[rollbar] Unhandled exception: Unhandled Promise rejection: configure Error: No usable generator found. {}

Then I added the respective setting to my local settings .vscode/settings.json.

{ "cmake.generator": "MSYS Makefiles" }

I got the following output:

[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!

So I extended my local settings.

{
  "cmake.generator": "MSYS Makefiles",
  "cmake.environment": {
    "CMAKE_AR": "C:/msys64/usr/bin/ar.exe",
    "CMAKE_MAKE_PROGRAM": "C:/msys64/usr/bin/make.exe"
  }
}

Got the same output as before. I also tried setting these variables in the CMakeLists.txt and as system environment variables.

What is the proper way to do this?

0 Answers
Related