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

Feature request: Allow running a custom target after configuring

Open nolange opened this issue 2 years ago • 5 comments

Brief Issue Summary

I use vscode for some QT Projekts, there require to run some tools to generate header / source files.

The problem is, that code indexers and other tools would ideally require those generated files. Also features like recompiling a source-file wont work because of missing generated files.

What needs to be done in my case:

# configure
cmake -DCMAKE_GLOBAL_AUTOGEN_TARGET=ON <PATH>
# post-configure
cmake --build . --target autogen
# only now many features will work correctly

I would like if I could configure a set of "post-configure" targets, like

    "cmake.configurePostTarget": [
        "autogen"
    ]

vscode should configure, then potentially check if the targets exists and start them or just try running them (failure is not fatal).

CMake Tools Diagnostics

No response

Debug Log

No response

Additional Information

No response

nolange avatar Oct 10 '23 10:10 nolange

@nolange It seems that your post-configure suggestion is to build the target. Instead of adding a post-configure step, couldn't you just build that target? You could possibly even create a task that does both of these steps.

gcampbell-msft avatar Oct 13 '23 13:10 gcampbell-msft

it is a build target, but it only generates header. sure i can do it manually now - thats what i do.

what i want is having this configured globally and done automatically everytime the project is configured ( cmake is run explicitely by the plugin)

nolange avatar Oct 13 '23 14:10 nolange

@nolange Ah, thanks for the additional understanding.

To make it clear, your ask is that there be some global CMake extension setting that a user can enable or set for specific targets, that always has the extension immediately build after configure.

Marking this as a feature request and putting it in our backlog for consideration for upcoming releases based on bandwidth. Thanks!

gcampbell-msft avatar Oct 24 '23 13:10 gcampbell-msft

with cmake 3.31 there is now a dedicated codegen target for some generators.

nolange avatar Nov 05 '24 06:11 nolange

with cmake 3.31 there is now a dedicated codegen target for some generators.

It would be really helpful to just having a setting that runs the codegen target. This will play really well with language servers(e.g. clangd)

Current experience:

  • Configure
  • clangd indexing partially runs because it is unable to find headers that are code generated (protofbuf codegen is a big example)
  • run your codegen target manually
  • Then indexing works

New experience:

  • Configure (extension figures out to run the codegen target)
  • clangd is happy and everyone is happy

sbairoliya avatar May 14 '25 21:05 sbairoliya

Yeah, the codegen target doesn't make that much sense if you have to go out of your way to run it when it's intended purpose was to be automatically run by IDEs. I was hoping that would exactly be what happens when I use the CODEGEN option for my custom commands.

oold avatar Jul 17 '25 16:07 oold