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.

CmakePresets: Selecting of build targets seems not to be supported or not working

See original GitHub issue

Brief Issue Summary

The CMake Tools when using kits and variants allow easy selection of the current build target using either a command or a selector in the toolbar next to the Build icon. It is very easy to switch between different compilation targets in multi-target cmake files or alternatively selecting of [all].

Example: 2021-05-13_12-47-51

2021-05-13_12-49-40

The new CMake Tools “CmakePresets” feature does unfortunately not offer changing the target. Neither is there a similar target icon/selector in the toolbar nor seems there to be a way to change the target otherwise. The Cmake: Set Build Target command is not even listed on my machine nor does running CMake: Set Debug Target work either, but at least the command is listed.

Snag_b337d2

Snag_b5c246

Platform and Versions

  • Operating System: Windows 10
  • CMake Version: 3.20.2
  • VSCode Version: 1.56.1
  • CMake Tools Extension Version: 1.7.3
  • Compiler/Toolchain: not relevant

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:4
  • Comments:21 (9 by maintainers)

github_iconTop GitHub Comments

4reactions
craigscott-crascitcommented, Sep 15, 2021

Hey folks, CMake co-maintainer here. I’m seeing this issue really hurting adoption of CMake presets among the user community. Anyone who works on a non-trivial sized project is going to be hitting this problem.

I was trying out the suggested workaround of using Shift+F7 to build a specific target, but I found that when I did that, I didn’t get a list of defined targets to pick from and instead had to manually type in a target name. No developer is going to be happy doing that every time they want to do a build in their day-to-day workflow. The combinatorial explosion that would result from having to create a build preset for every target and every configuration is also not practical and not friendly to users. There’s some further context in the upstream CMake issue: https://gitlab.kitware.com/cmake/cmake/-/issues/22538

Is it possible to consider @hwmaier 's suggestion and re-enable the “CMake: Set Build Target” code, at least for now while a deeper solution is being worked on? That would at least give users a considerably better experience with presets in the short term for what seems like pretty low cost (given the code is already there and was used previously before presets came along). Even if it was hidden behind some kind of experimental or “use at your own risk” flag, that would be considerably better than what we have now.

And to re-iterate, this is really hurting adoption.

2reactions
KUGA2commented, Jun 29, 2021

We got excactly the same usecase as @hwmaier.

Multiple platforms and toolchains and big projects with many targets. Users want to build only a single targets, they currently develop for faster test build or debug.

PS: the proposed target selection statusbar button should also be used for the play and debug button! image (similar to this request https://github.com/microsoft/vscode-cmake-tools/issues/1941)

Read more comments on GitHub >

github_iconTop Results From Across the Web

CMake: Cannot build targets after configure
Upon configuring my project, all of the targets are listed in the CMake targets view, but right-clicking and selecting “Build” does not do...
Read more >
Configure and build with CMake Presets in Visual Studio
To build the entire project, select Build > Build All from the main menu. It's the same as running cmake --build --preset <buildPreset>...
Read more >
CMake presets cause combinatorial explosion (#22538) · Issues
From my experience trying to use build presets on real projects so far, most of the usability problems seem to stem from this...
Read more >
Level Up Your Debugging Workflow with CMake Presets ...
In this session, we'll get a simple embedded project up and running on a Raspberry Pi using CMake Presets and the CMake Tools...
Read more >
How do I activate C++ 11 in CMake? - Stack Overflow
@tuple_cat You can do it target-based as well. But be aware that CXX_STANDARD does not work on MSVC, so basically you have to...
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