"Set Build Target" list is empty after configure even though "Project Outline" pane contains targets
See original GitHub issueBrief Issue Summary
CMake Tools has been working fine for me for ages, but suddenly it’s started exhibiting a problem this afternoon. Normally the option to pick a build target would be populated with items from CMake, but now it is always empty. This happens even after I configure from within VS Code. In this situation the Project Outline pane is populated with items correctly, so something is working differently in the target picker type-in. Is there some logging I can enable to debug this? Perhaps some cache files somewhere have become corrupted. I’ve restarted VS Code, rebooted the machine, even deleted and recreated my build folders to no avail.
Expected:
- Configure with VS Code
- Examine Project Outline pane and see it is correctly populated with targets
- Click build target button on bottom toolbar, or use “CMake: Set Build Target” from command palette
- Popup should be populated with target names
Apparent Behavior:
- Configure with VS Code
- Examine Project Outline pane and see it is correctly populated with targets
- Click build target button on bottom toolbar, or use “CMake: Set Build Target” from command palette
- No targets are shown and type-in accepts free text
CMake Tools Log
Contains sensitive info. If pointed at some further logging I can investigate further on my end.
Platform and Versions
- Operating System: macOS Catalina 10.15.6
- CMake Version: 3.18.4
- VSCode Version: 1.50.1
- CMake Tools Extension Version: 1.4.2
- Compiler/Toolchain: Apple Clang 11.0.3
Additional Information
I do see this in the CMake output, but according to the reported issue it should have no impact:
[cmakefileapi-parser] Code model version (2.1) of cmake-file-api is unexpected. Expecting (2.0). IntelliSense configuration may be incorrect.
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (2 by maintainers)

Top Related StackOverflow Question
Thanks @andreeis. I started hearing that colleagues were experiencing the same issue, which showed it wasn’t just some local cache problem on my laptop. I started looking at our recent source repo history and narrowed it down to a particular commit where someone had added some CMake lines. It boils down to this:
I guess CMake Tools doesn’t like having the value of
CMAKE_BUILD_TYPEchanged even if it’s just capitalisation - case-sensitivity somewhere? Changing the CMake codee to use a separate temporary local name seems to fix the issue.There is perhaps something that could be done in VS Code to catch this. Upping
cmake.loggingLevelI sometimes saw this when it went wrong:But there was no other message in the IDE - shouldn’t an error toast or something be displayed? That might have caught the issue sooner on our end. Oddly though, even in cases where it was going wrong, it would sometimes claim a return code of 0 instead. I’m not sure whether this is coming from CMake itself or the extension.
In my case, the target list became empty when
CMAKE_BUILD_TYPEwas changed (either TOUPPER or set to a new value). Adding either of the following lines to CMakeLists.txt can reproduce the problem: