question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"Set Build Target" list is empty after configure even though "Project Outline" pane contains targets

See original GitHub issue

Brief 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:

  1. Configure with VS Code
  2. Examine Project Outline pane and see it is correctly populated with targets
  3. Click build target button on bottom toolbar, or use “CMake: Set Build Target” from command palette
  4. Popup should be populated with target names

Apparent Behavior:

  1. Configure with VS Code
  2. Examine Project Outline pane and see it is correctly populated with targets
  3. Click build target button on bottom toolbar, or use “CMake: Set Build Target” from command palette
  4. 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:open
  • Created 3 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
andrewmcdonald-oxbcommented, Nov 10, 2020

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:

string( TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE )
if( CMAKE_BUILD_TYPE STREQUAL "DEBUG" OR CMAKE_BUILD_TYPE STREQUAL "COVERAGE")
  # ... CMake code ...
endif()

I guess CMake Tools doesn’t like having the value of CMAKE_BUILD_TYPE changed 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.loggingLevel I sometimes saw this when it went wrong:

[driver] Failed to configure project
[extension] [5482] cmake.configure finished (returned -1)

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.

0reactions
rewqazxvcommented, Sep 26, 2022

In my case, the target list became empty when CMAKE_BUILD_TYPE was changed (either TOUPPER or set to a new value). Adding either of the following lines to CMakeLists.txt can reproduce the problem:

set(CMAKE_BUILD_TYPE no_type)
string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Customize your build - MSBuild - Microsoft Learn
Learn about several extensibility hooks you can use to customize MSBuild projects that use the standard build process.
Read more >
Configuring a new target in your project - Apple Developer
To view and add dependencies, select a target and open its build phase settings. The Dependencies build phase contains the targets that Xcode...
Read more >
12. Debugging Makefiles - Managing Projects with GNU Make ...
To use it, just set the list of variables to print on the command line, and include the debug target: $ make V="USERNAME...
Read more >
Makefile projects | CLion Documentation - JetBrains
The list of the open-source projects that Makefile support has been ... If you leave the Build target field empty, CLion will take...
Read more >
Building in Visual Studio Code with a Makefile - Earthly Blog
Microsoft announced recently a new Visual Studio Code extension to handle Makefiles. This extension provides a set of commands to the editor ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found