Vscode-cmake-tools: Remote compile and run C++ code

Created on 29 Nov 2018  路  18Comments  路  Source: microsoft/vscode-cmake-tools

Is it possible to configure cmake tools to compile, build and run on remote device when ssh, sftp available?

Feature Request configure remote

Most helpful comment

This is now available in vscode: https://code.visualstudio.com/blogs/2019/05/02/remote-development

However, CMake Tools hangs with CMake Tools initializing...: Creating backend for me...

All 18 comments

Not currently. This is a feature I've wanted to look into, though, especially as I do a lot of development via Docker.

I'd be interested in how this would work with cpptools, though. I do not know if they respect remote filesystems at the moment.

@vector-of-bool I develop in docker currently as well. I can use vscode-cpptools but I have to create a docker volume to map my files back to the host. However, is there any way to prefix build commands with docker exec -it ...? I believe I saw you mention that this would be incompatible with cmake-server somewhere though, but I can't find where that was.

When using docker there is two options:

1) you use docker as a "cross-target" and you cross-compile from the host, thus you speak to the CMake server on the host, and cmake is executed on the host, compilation as well etc...

2) you use docker as a "native-target" so beside executing vscode on the host all other dev process: running cmake, cmake server, compiling etc... is done in the docker.

I personally use 2) and since there is no "in-docker" support with CMakeTools I do run vscode in the docker as well :-)
I don't think 1) is useful when using docker.

This works perfectly well. In this scheme I install an ssh server in the docker container, then I ssh into it and let ssh ForwardX11 the display to the host I'm ssh-ing from.
This is a easy setup because vscode+CMakeTools can talk to cmake-server (https://cmake.org/cmake/help/v3.7/manual/cmake-server.7.html) "as usual".

If you want to keep vscode outside docker you should find a way to make CMakeTools talk to cmake-server named pipe in the docker.

This should be [theoretically] possible if the named pipe is in a docker mounted volume which thus
can be seen outside (for vscode/cmaketools) and inside the docker (for cmake-server).

@TheErk is correct in that a named pipe could be used to talk to CMake in a docker container. I don't have much doubt in being able to use a remote CMake. It could even be done over an SSH tunnel to a completely remote box as well.

If I were to support such a thing, I'd also like to see what it would take in the C++ editing department as well. Since those are driven by a separate extension, I wouldn't be able to do that on my own.

Some trouble arises that this "remote" functionality isn't really specific to either CMake nor cpptools. It'd almost warrant a third extension built to support "remote" magic in this way.

I'll be bold and summon a cpptools dev... @bobbrow !

And idea what it would take for cpptools to support "remote"-ness?

I suspect it would take a bit of work to implement the vscode.FileSystemProvider API. We started tagging remote filesystem issues to try to get an idea as to how urgent the need is for first-class support. We only support file:/// URIs right now, so we currently require users to mount/map their remote filesystems before using our extension.

I have heard mention of this sshfs extension, but haven't played around with it yet.

Even if I use ssh go into my docker container. May be requiring ssh is too much?
I tend to think that when your do development your source are usually mapped from host to docker through a mounted docker volume already. The only weird thing is you usually "see" the very same source at different absolute path inside docker as you see them outside docker.

May be that if cpptools was simply "aware" of the remapping of the source you may work with the source on the host directly? This is a wild guess.

There is a bunch of "remote editing" extension for vscode, see e.g.: remote fs for example.
I did not tested [yet].

I'm no vscode extension developer so I don't know whether if this uses vscode.FileSystemProvider API, but may be cpptools could use one of those extension.

I use docker too. To workaround running cmake inside container I've created dk-cmake command. But there is no way to specify dk-ninja command

I'd be very glad to see this implemented. I do all my builds inside a docker container.

I would also like this feature. I usually develop on MacOS, but sometimes some I need to debug some Linux-specific part of my code. At the moment I SSH into my Linux server and do minimal code changes in vim while compiling and running with cmake manually. And debugging via command-line GDB via SSH is a nightmare.

It would be great if VSCode had the ability similar to this one in full Visual Studio, which enables full-scale development of your code on Windows while compiling and debugging on remote Linux machine.

This is now available in vscode: https://code.visualstudio.com/blogs/2019/05/02/remote-development

However, CMake Tools hangs with CMake Tools initializing...: Creating backend for me...

I get the same issue on Windows, works fine on Ubuntu 18.04

Extension is blocked on calling "Rollback opt-in" which not appear on Remote-SSH (i don't understand why)

Try "cmake.rollbar-optin3": false in settings.json config file. It help me.

Here is a similar issue.

Any updates on this in 2020, I'd love to be able to use cmake-tools with VSCode remote sessions?

It should work with the latest CMake. Reactivate if you encounter any other issues.

I tried using CMake debugging in a remote session, but I'm getting this error message:

target_name_undefined

As you can see in the toolbar, the target is set to dispatch. Any idea what could be causing this?

[dispatch] is the build target. It's unclear why the extension didn't ask you to select a debug target. Can you open a new issue with more details about your project?

Indeed, I just needed to manually configure the CMake Build Target. Thank you, it now correctly launches the specified debug target.

Was this page helpful?
0 / 5 - 0 ratings