I created cmake project in vs code with cmake extension using cmake: quick start. When i try to run or debug project it fails with error. I found that cmake extension put incorrect CMAKE_MAKE_PROGRAM:FILEPATH in CMakeCache.txt
CMAKE_MAKE_PROGRAM:FILEPATH=C:/Program Files/Delphi 7/bin/make.exe
so, when i changed it to
CMAKE_MAKE_PROGRAM:FILEPATH=C:/Program Files/msys64/mingw64/bin/mingw32-make.exe
problem disappeared.
Is it possible somehow to change CMake settings, so it will generate this line correctly without need to change it?
CodePudding user response:
If you weren't using VS Code and were just using the command-line, one good way would be to invoke CMake like so: cmake -S . -B <build-path> -D CMAKE_MAKE_PROGRAM="C:/Program Files/msys64/mingw64/bin/mingw32-make.exe" <rest of options>
But since you're using VS Code and the VS Code extension invokes CMake for you, the best solution is probably to create a CMakePresets.json
or CMakeUserPresets
file beside your root CMakeLists.txt file and define a configurePreset where one of the cacheVariables is "CMAKE_MAKE_PROGRAM": "C:/Program Files/msys64/mingw64/bin/mingw32-make.exe"
. CMake presets are a way of defining common configurations for a CMake project. A CMakePresets.json file is for defining presets that could be useful to anyone, and a CMakeUserPresets.json file is for each user to define presets that are useful just for them. If that path to a make
program is a common path that is likely to be the same for other Windows users, then use a CMakePresets.json
file. The VS Code extension has integration for preset files. Once you define one, you can select it in the VS Code UI.
If you feel like CMake presets is too much to learn about at the moment / overwhelming, and you're the only one working on your project at the moment, a simple temporary workaround is to just define it in your .vscode/settings.json like so:
"cmake.configureSettings": {
"CMAKE_MAKE_PROGRAM": "C:/Program Files/msys64/mingw64/bin/mingw32-make.exe"
}
The problem with this workaround is that it's not going to work for anyone else who tries to use your vscode setup and who doesn't have a make program at that exact location, or has it but doesn't want to use that specific one.