vscode-cmake-tools
vscode-cmake-tools copied to clipboard
Empty CMAKE_BUILD_TYPE prevents active target selection in the status bar
Brief Issue Summary
If the CMAKE_BUILD_TYPE cache variable is set to an empty string, the active target cannot be selected via the status bar, but can still be selected manually or through the Project Outline tab.
Expected:
- Set the CMAKE_BUILD_TYPE variable to empty string:
set(CMAKE_BUILD_TYPE "" CACHE STRING "" FORCE)
- Click on the [<target>] button in the status bar
- Menu with available targets appears for selection
- Other plugin functions still work as expected.
Apparent Behavior:
- Set the CMAKE_BUILD_TYPE variable to empty string:
set(CMAKE_BUILD_TYPE "" CACHE STRING "" FORCE)
- Click on the [<target>] button in the status bar
- Menu appears but with no available targets. Still allows manual target name entry.
- Following error is logged to the "Output" pane:
[cms-driver] Found no matching code model for the current build type. This shouldn't be possible
- Other plugin functions still work as expected.
Platform and Versions
- Operating System: macOS
- CMake Version: 3.15.3
- VSCode Version: 1.38
- CMake Tools Extension Version: 1.1.3
- Compiler/Toolchain: clang-1001.0.46.4
Other Notes/Information
I recognize that it is not common to set CMAKE_BUILD_TYPE to an empty string. The Project Outline tab still functions properly, and the active target can still be set there via right-click on a target and clicking "Set as default target".
It's working for me on my MacBook. I was able to reproduce the symptoms on Windows, but only briefly - it would eventually resolve and the menu would populate the targets.
Is your project open source? Can I clone it?
I've created a small project that consistently demonstrates this problem. It is configured on a Windows machine, and I've included a cmake-kits.json file to further show the toolchain I'm using (although it should be noted that the generator used is actually Ninja--I'm not sure why it won't use the Visual Studio generator as set in the cmake-kits file)
The repo is here: https://github.com/dstodev/cmake-tools-bug
Thanks for the project. I debugged this and I understand the issue better now. The targets that are displayed are filtered against the current build type. The extension doesn't expect you to change this value because the CMake server usually sends back the data for the active build type. When it comes back without the matching build type, the extension doesn't know what to do with it.
We can probably patch this specific case where you clear the build type, but what is the use case where this is needed?
The CMAKE_BUILD_TYPE variable is cleared in a codebase that I did not author in order to stop CMake from doing some other stuff that is also dependent on the value of the variable.
I'll be working in this codebase, and it has a large amount of targets, so having this feature work with this codebase would be nice.
Thank you!
+1
We should investigate and see if this still reproduces in 1.19.
@gcampbell-msft @dstodev I am not able to reproduce this issue anymore on 1.19.13 with the repo provided. Just so I understand if this is expected behavior, these are the targets available whether or not the build type is set:
@MartinsSmirnovs I see you "+1"d this in 2022. Are you still encountering this issue?
@snehara99 Sorry, I do not have an ability to reproduce this anymore.
@MartinsSmirnovs Thanks for confirming! Closing as can't repro