Brief Issue Summary
When switching the generator to Ninja and updating CMAKE_MAKE_PROGRAM accordingly, CMake Tools still invokes CMake with a stale make value.
This results in a broken configuration where Ninja is selected as the generator, but GNU Make is used as the make program.
Steps to Reproduce
- Open the attached project in Visual Studio Code
- Run CMake: Configure (build)
- Delete the build directory (out)
- Close and open VS Code
- Edit CMakePresets.json:
Change generator to "Ninja"
Save the file
- Edit CMakeUserPresets.json:
Set:
"cacheVariables": {
"CMAKE_MAKE_PROGRAM": "ninja"
}
Save the file
7) Run CMake: Configure
Actual Behavior
CMake is invoked with:
-DCMAKE_MAKE_PROGRAM=make
-G Ninja
This causes the configuration to fail because GNU Make is incorrectly used as the Ninja executable.
Workaround
Restart VS Code
Possible solution
A colleague of mine investigated the issue deeper:
CMakeProject.getCMakeDriverInstance sets drv.onCodeModelChanged.
|
this.codeModelDriverSub = drv.onCodeModelChanged(cm => this._codeModelContent.set(cm)); |
But CMakeProject.reloadCMakeDriver does not.
|
private async reloadCMakeDriver() { |
One possible solution to this problem is to move the event binding
if (this.codeModelDriverSub) {
this.codeModelDriverSub.dispose();
}
this.codeModelDriverSub = drv.onCodeModelChanged(cm => this._codeModelContent.set(cm));
from getCMakeDriverInstance into startNewCMakeDriver
CMake Tools Diagnostics
{
"os": "linux",
"vscodeVersion": "1.114.0",
"cmtVersion": "1.22.28",
"configurations": [
{
"folder": "/home/codasip.com/adam.bartos/codasip/workspaces/cmake",
"cmakeVersion": "3.26.5",
"configured": true,
"generator": "Ninja",
"usesPresets": true,
"compilers": {}
}
],
"cpptoolsIntegration": {
"isReady": false,
"hasCodeModel": false,
"activeBuildType": "",
"buildTypesSeen": [],
"requests": [],
"responses": [],
"partialMatches": [],
"targetCount": 0,
"executablesCount": 0,
"librariesCount": 0,
"targets": []
},
"settings": [
{
"communicationMode": "automatic",
"useCMakePresets": "auto",
"configureOnOpen": false
}
]
}
Debug Log
[bookmarks] Loaded 0 bookmarks
[proc] Executing command: /usr/bin/cmake --version
[proc] Executing command: /usr/bin/cmake -E capabilities
[main] Safe constructing new CMakeProject instance
[variant] Constructing VariantManager
[main] Constructing new CMakeProject instance
[main] Starting CMake Tools second-phase init
[expand] expanded ${workspaceFolder}
[kit] Reading kits file /home/codasip.com/adam.bartos/.local/share/CMakeTools/cmake-tools-kits.json
[kit] Successfully loaded 1 kits from /home/codasip.com/adam.bartos/.local/share/CMakeTools/cmake-tools-kits.json
[kit] Not reading non-existent kits file: /home/codasip.com/adam.bartos/codasip/workspaces/cmake/.vscode/cmake-kits.json
[presetController] Reading presets file /home/codasip.com/adam.bartos/codasip/workspaces/cmake/CMakePresets.json
[presetController] Reading and validating the presets file "/home/codasip.com/adam.bartos/codasip/workspaces/cmake/CMakePresets.json"
[presetController] Successfully validated /home/codasip.com/adam.bartos/codasip/workspaces/cmake/CMakePresets.json against presets schema
[proc] Executing command: uname -s
[presetController] Expanding presets file /home/codasip.com/adam.bartos/codasip/workspaces/cmake/CMakePresets.json
[preset] Configure preset _build: No binaryDir specified, using default value "${sourceDir}/out/build/${presetName}"
[expand] expanded ${sourceDir}/out/build/${presetName}
[presetController] Successfully expanded presets file /home/codasip.com/adam.bartos/codasip/workspaces/cmake/CMakePresets.json
[presetController] Reading presets file /home/codasip.com/adam.bartos/codasip/workspaces/cmake/CMakeUserPresets.json
[presetController] Reading and validating the presets file "/home/codasip.com/adam.bartos/codasip/workspaces/cmake/CMakeUserPresets.json"
[presetController] Successfully validated /home/codasip.com/adam.bartos/codasip/workspaces/cmake/CMakeUserPresets.json against presets schema
[presetController] Expanding presets file /home/codasip.com/adam.bartos/codasip/workspaces/cmake/CMakeUserPresets.json
[presetController] Successfully expanded presets file /home/codasip.com/adam.bartos/codasip/workspaces/cmake/CMakeUserPresets.json
[main] Resolving the selected configure preset
[preset] Configure preset build: No binaryDir specified, using default value "${sourceDir}/out/build/${presetName}"
[expand] expanded ${sourceDir}/out/build/${presetName}
[main] Loading new configure preset into CMake driver
[main] Resolving the selected build preset
[main] Loading new build preset into CMake driver
[main] Resolving the selected test preset
[main] Resolving the selected test preset
[main] Loading new test preset into CMake driver
[main] Resolving the selected package preset
[main] Resolving the selected package preset
[main] Loading new package preset into CMake driver
[main] Resolving the selected workflow preset
[main] Resolving the selected workflow preset
[preset] Configure preset build: No binaryDir specified, using default value "${sourceDir}/out/build/${presetName}"
[expand] expanded ${sourceDir}/out/build/${presetName}
[main] Loading new workflow preset into CMake driver
[main] CMakeProject instance initialization complete.
[extension] Attempting to use cache to configure workspace file:///home/codasip.com/adam.bartos/codasip/workspaces/cmake
[main] Starting new CMake driver
[main] Starting CMake driver
[cmakefileapi-driver] Creating instance of CMakeFileApiDriver
[driver] Initializing base driver using preset
[driver] CMakeDriver configure preset set to build
[driver] CMakeDriver build preset set to __defaultBuildPreset__
[driver] CMakeDriver test preset set to __defaultTestPreset__
[driver] CMakeDriver package preset set to __defaultPackagePreset__
[driver] CMakeDriver workflow preset set to __defaultWorkflowPreset__
[main] Unable to configure with existing cache
[presetController] Reading presets file /home/codasip.com/adam.bartos/codasip/workspaces/cmake/CMakePresets.json
[presetController] Reading and validating the presets file "/home/codasip.com/adam.bartos/codasip/workspaces/cmake/CMakePresets.json"
[presetController] Successfully validated /home/codasip.com/adam.bartos/codasip/workspaces/cmake/CMakePresets.json against presets schema
[presetController] Expanding presets file /home/codasip.com/adam.bartos/codasip/workspaces/cmake/CMakePresets.json
[preset] Configure preset _build: No binaryDir specified, using default value "${sourceDir}/out/build/${presetName}"
[expand] expanded ${sourceDir}/out/build/${presetName}
[presetController] Successfully expanded presets file /home/codasip.com/adam.bartos/codasip/workspaces/cmake/CMakePresets.json
[presetController] Reading presets file /home/codasip.com/adam.bartos/codasip/workspaces/cmake/CMakeUserPresets.json
[presetController] Reading and validating the presets file "/home/codasip.com/adam.bartos/codasip/workspaces/cmake/CMakeUserPresets.json"
[presetController] Successfully validated /home/codasip.com/adam.bartos/codasip/workspaces/cmake/CMakeUserPresets.json against presets schema
[presetController] Expanding presets file /home/codasip.com/adam.bartos/codasip/workspaces/cmake/CMakeUserPresets.json
[presetController] Successfully expanded presets file /home/codasip.com/adam.bartos/codasip/workspaces/cmake/CMakeUserPresets.json
[main] Resolving the selected configure preset
[preset] Configure preset build: No binaryDir specified, using default value "${sourceDir}/out/build/${presetName}"
[expand] expanded ${sourceDir}/out/build/${presetName}
[main] Shutting down CMake driver
[main] Loading new configure preset into CMake driver
[driver] Switching to configure preset: build
[preset] Need clean: configure preset changed
[driver] CMakeDriver configure preset set to build
[main] Resolving the selected build preset
[main] Loading new build preset into CMake driver
[main] Resolving the selected test preset
[main] Resolving the selected test preset
[main] Loading new test preset into CMake driver
[main] Resolving the selected package preset
[main] Resolving the selected package preset
[main] Loading new package preset into CMake driver
[main] Resolving the selected workflow preset
[main] Resolving the selected workflow preset
[preset] Configure preset build: No binaryDir specified, using default value "${sourceDir}/out/build/${presetName}"
[expand] expanded ${sourceDir}/out/build/${presetName}
[main] Loading new workflow preset into CMake driver
[presetController] Reading presets file /home/codasip.com/adam.bartos/codasip/workspaces/cmake/CMakePresets.json
[presetController] Reading and validating the presets file "/home/codasip.com/adam.bartos/codasip/workspaces/cmake/CMakePresets.json"
[presetController] Successfully validated /home/codasip.com/adam.bartos/codasip/workspaces/cmake/CMakePresets.json against presets schema
[presetController] Expanding presets file /home/codasip.com/adam.bartos/codasip/workspaces/cmake/CMakePresets.json
[preset] Configure preset _build: No binaryDir specified, using default value "${sourceDir}/out/build/${presetName}"
[expand] expanded ${sourceDir}/out/build/${presetName}
[presetController] Successfully expanded presets file /home/codasip.com/adam.bartos/codasip/workspaces/cmake/CMakePresets.json
[presetController] Reading presets file /home/codasip.com/adam.bartos/codasip/workspaces/cmake/CMakeUserPresets.json
[presetController] Reading and validating the presets file "/home/codasip.com/adam.bartos/codasip/workspaces/cmake/CMakeUserPresets.json"
[presetController] Successfully validated /home/codasip.com/adam.bartos/codasip/workspaces/cmake/CMakeUserPresets.json against presets schema
[presetController] Expanding presets file /home/codasip.com/adam.bartos/codasip/workspaces/cmake/CMakeUserPresets.json
[presetController] Successfully expanded presets file /home/codasip.com/adam.bartos/codasip/workspaces/cmake/CMakeUserPresets.json
[main] Resolving the selected configure preset
[preset] Configure preset build: No binaryDir specified, using default value "${sourceDir}/out/build/${presetName}"
[expand] expanded ${sourceDir}/out/build/${presetName}
[main] Starting new CMake driver
[main] Starting CMake driver
[cmakefileapi-driver] Creating instance of CMakeFileApiDriver
[driver] Initializing base driver using preset
[driver] CMakeDriver configure preset set to build
[driver] CMakeDriver build preset set to __defaultBuildPreset__
[driver] CMakeDriver test preset set to __defaultTestPreset__
[driver] CMakeDriver package preset set to __defaultPackagePreset__
[driver] CMakeDriver workflow preset set to __defaultWorkflowPreset__
[main] Loading new configure preset into CMake driver
[main] Resolving the selected build preset
[main] Loading new build preset into CMake driver
[driver] Switching to build preset: __defaultBuildPreset__
[driver] CMakeDriver build preset set to __defaultBuildPreset__
[main] Resolving the selected test preset
[main] Resolving the selected test preset
[main] Loading new test preset into CMake driver
[driver] Switching to test preset: __defaultTestPreset__
[driver] CMakeDriver test preset set to __defaultTestPreset__
[main] Resolving the selected package preset
[main] Resolving the selected package preset
[main] Loading new package preset into CMake driver
[driver] Switching to package preset: __defaultPackagePreset__
[driver] CMakeDriver package preset set to __defaultPackagePreset__
[main] Resolving the selected workflow preset
[main] Resolving the selected workflow preset
[preset] Configure preset build: No binaryDir specified, using default value "${sourceDir}/out/build/${presetName}"
[expand] expanded ${sourceDir}/out/build/${presetName}
[main] Loading new workflow preset into CMake driver
[driver] Switching to workflow preset: __defaultWorkflowPreset__
[driver] CMakeDriver workflow preset set to __defaultWorkflowPreset__
[extension] [1607] cmake.configure started
[main] Configuring project: cmake
[main] Saving open files before configure/build
[driver] Start configure
[driver] Running pre-configure checks and steps
[cmakefileapi-driver] Configuring using preset
[cmakefileapi-driver] Invoking CMake /usr/bin/cmake with arguments ["-DCMAKE_MAKE_PROGRAM=make","-S","/home/codasip.com/adam.bartos/codasip/workspaces/cmake","-B","/home/codasip.com/adam.bartos/codasip/workspaces/cmake/out/build/build","-G","Ninja"]
[proc] Executing command: /usr/bin/cmake -DCMAKE_MAKE_PROGRAM=make -S /home/codasip.com/adam.bartos/codasip/workspaces/cmake -B /home/codasip.com/adam.bartos/codasip/workspaces/cmake/out/build/build -G Ninja
[cmake] -- The C compiler identification is GNU 8.5.0
[cmake] -- The CXX compiler identification is GNU 8.5.0
[cmake] -- Detecting C compiler ABI info
[cmake] CMake Error:
[cmake] The detected version of Ninja (GNU Make 4.2.1
[cmake]
[cmake] Built for x86_64-redhat-linux-gnu
[cmake]
[cmake] Copyright (C) 1988-2016 Free Software Foundation, Inc.
[cmake]
[cmake] License GPLv3+: GNU GPL version 3 or later
[cmake] <http://gnu.org/licenses/gpl.html>
[cmake]
[cmake] This is free software: you are free to change and redistribute it.
[cmake]
[cmake] There is NO WARRANTY, to the extent permitted by law.) is less than the
[cmake] version of Ninja required by CMake (1.3).
[cmake]
[cmake]
[cmake] CMake Error at /usr/share/cmake/Modules/CMakeDetermineCompilerABI.cmake:57 (try_compile):
[cmake] Failed to generate test project build system.
[cmake] Call Stack (most recent call first):
[cmake] /usr/share/cmake/Modules/CMakeTestCCompiler.cmake:26 (CMAKE_DETERMINE_COMPILER_ABI)
[cmake] CMakeLists.txt:2 (project)
[cmake]
[cmake]
[cmake] -- Configuring incomplete, errors occurred!
[proc] The command: /usr/bin/cmake -DCMAKE_MAKE_PROGRAM=make -S /home/codasip.com/adam.bartos/codasip/workspaces/cmake -B /home/codasip.com/adam.bartos/codasip/workspaces/cmake/out/build/build -G Ninja exited with code: 1
[extension] [1607] cmake.configure finished (returned 1)
Additional Information

cmake.zip
Brief Issue Summary
When switching the generator to Ninja and updating CMAKE_MAKE_PROGRAM accordingly, CMake Tools still invokes CMake with a stale make value.
This results in a broken configuration where Ninja is selected as the generator, but GNU Make is used as the make program.
Steps to Reproduce
Change generator to "Ninja"
Save the file
Set:
Save the file
7) Run CMake: Configure
Actual Behavior
CMake is invoked with:
This causes the configuration to fail because GNU Make is incorrectly used as the Ninja executable.
Workaround
Restart VS Code
Possible solution
A colleague of mine investigated the issue deeper:
CMakeProject.getCMakeDriverInstancesetsdrv.onCodeModelChanged.vscode-cmake-tools/src/cmakeProject.ts
Line 1513 in 7138e9e
But
CMakeProject.reloadCMakeDriverdoes not.vscode-cmake-tools/src/cmakeProject.ts
Line 1249 in 7138e9e
One possible solution to this problem is to move the event binding
from
getCMakeDriverInstanceintostartNewCMakeDriverCMake Tools Diagnostics
{ "os": "linux", "vscodeVersion": "1.114.0", "cmtVersion": "1.22.28", "configurations": [ { "folder": "/home/codasip.com/adam.bartos/codasip/workspaces/cmake", "cmakeVersion": "3.26.5", "configured": true, "generator": "Ninja", "usesPresets": true, "compilers": {} } ], "cpptoolsIntegration": { "isReady": false, "hasCodeModel": false, "activeBuildType": "", "buildTypesSeen": [], "requests": [], "responses": [], "partialMatches": [], "targetCount": 0, "executablesCount": 0, "librariesCount": 0, "targets": [] }, "settings": [ { "communicationMode": "automatic", "useCMakePresets": "auto", "configureOnOpen": false } ] }Debug Log
Additional Information
cmake.zip