vscode-cmake-tools icon indicating copy to clipboard operation
vscode-cmake-tools copied to clipboard

Empty CMAKE_BUILD_TYPE prevents active target selection in the status bar

Open dstodev opened this issue 5 years ago • 6 comments

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:

  1. Set the CMAKE_BUILD_TYPE variable to empty string: set(CMAKE_BUILD_TYPE "" CACHE STRING "" FORCE)
  2. Click on the [<target>] button in the status bar
  3. Menu with available targets appears for selection
  4. Other plugin functions still work as expected.

Apparent Behavior:

  1. Set the CMAKE_BUILD_TYPE variable to empty string: set(CMAKE_BUILD_TYPE "" CACHE STRING "" FORCE)
  2. Click on the [<target>] button in the status bar
  3. Menu appears but with no available targets. Still allows manual target name entry.
  4. 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
  5. 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".

dstodev avatar Sep 09 '19 21:09 dstodev

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?

bobbrow avatar Sep 10 '19 21:09 bobbrow

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

dstodev avatar Sep 10 '19 21:09 dstodev

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?

bobbrow avatar Sep 11 '19 20:09 bobbrow

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!

dstodev avatar Sep 11 '19 21:09 dstodev

+1

MartinsSmirnovs avatar Aug 29 '22 14:08 MartinsSmirnovs

We should investigate and see if this still reproduces in 1.19.

gcampbell-msft avatar Jun 25 '24 13:06 gcampbell-msft

@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: image

snehara99 avatar Jul 01 '24 16:07 snehara99

@MartinsSmirnovs I see you "+1"d this in 2022. Are you still encountering this issue?

snehara99 avatar Jul 01 '24 16:07 snehara99

@snehara99 Sorry, I do not have an ability to reproduce this anymore.

MartinsSmirnovs avatar Jul 07 '24 11:07 MartinsSmirnovs

@MartinsSmirnovs Thanks for confirming! Closing as can't repro

snehara99 avatar Jul 08 '24 16:07 snehara99