Vscode-cmake-tools: Use gcc 8(WSL in Windows 10) as a cmake-tools toolkit

Created on 6 Oct 2018  路  7Comments  路  Source: microsoft/vscode-cmake-tools

Brief Issue Summary

I have a gcc-8 compiler installed on my WSL (UBUNTU 18.04) inside of my windows 10 machine. I was wondering if there is any possibility that your CMake tool can see that compiler as a toolkit.

Expected:

  1. Execute "CMake: Scan for Kits"
  2. GCC via WSL will be seen.

Apparent Behavior:

  1. Execute "CMake: Scan for Kits"
  2. Only sees available kits in my windows machine but not in my WSL.

Platform and Versions

  • Operating System: Windows 10, version 1803
  • CMake Version: 3.10.2 (On my WSL) None on my Windows 10.
  • VSCode Version: 1.27.2
  • CMake Tools Extension Version: 1.1.2
  • Compiler/Toolchain: gcc 8.2 (On my WSL) None on my Windows 10
Feature Request help wanted

All 7 comments

I'm not a WSL user (I use MSVC for most Windows work), but this is a reasonable request. I am not sure what it would take to implement, but I'd gladly accept any help in implementing this! I may just have to break open WSL and figure it out on my own...

Im happy that this is possible! Sad to say im just a user of WSL, and dont have enough experience on how to approach this either.

But for now I'll still keep using your tool, and will send feedback as I go. Thank You!

I'm tring to implement wsl support with ssh2 (base.exe should be easier ) and cmake-server --debug mode, and use stdin for input, everything works fine, except compileCommands won't be able to work due to cpp-tools limitation.

I'm tring to implement wsl support with ssh2 (base.exe should be easier ) and cmake-server --debug mode, and use stdin for input, everything works fine, except compileCommands won't be able to work due to cpp-tools limitation.

Can you provide some details on how you did this? I'm very interested. I'm currently using CLion which has built-in support for CMake and WSL using ssh, but I'd love to have support in VSCode

@ChisholmKyle
First of all, you should know that we could run Linux command directly with bash -c in cmd

bash -c "ls -l"
bash -c  "/home/xvan/cmake-3.14.3-Linux-x86_64/bin/cmake .."

Now we have cmake-server with command cmake -E server, we could run it with cmd, and we also need --debug to enable stdin/stdout instead of pipe

bash -c  "/home/xvan/cmake-3.14.3-Linux-x86_64/bin/cmake -E server --debug"

With Node.js

const { spawn } = require('child_process')
let child = spawn("bash", ["-c", "/home/xvan/cmake-3.14.3-Linux-x86_64/bin/cmake -E server --experimental --debug"])
let shake = false
child.stdout.on('data', (chunk) => {
    chunk.toString().split("\n").forEach(element => {
        console.log(element)
    });
    if (!shake) {
        child.stdin.write(`
[== "CMake Server" ==[
{"cookie":"zimtstern","type":"handshake","protocolVersion":{"major":1},
"sourceDirectory":"/mnt/c/Users/xVan/Desktop/cmake-test", "buildDirectory":"/mnt/c/Users/xVan/Desktop/cmake-test/build",
"generator":"Unix Makefiles"}
]== "CMake Server" ==]
    `)
        shake = true
    }
})

And you will get:

[== "CMake Server" ==[
 {"supportedProtocolVersions":[{"isExperimental":true,"major":1,"minor":2}],"type":"hello"}
]== "CMake Server" ==]
[== "CMake Server" ==[
{"cookie":"zimtstern","inReplyTo":"handshake","type":"reply"}
]== "CMake Server" ==]

The rest is read and write with the specific protocal
You can read more info about cmake-server here

Hope it will help.

If you use the Remote - WSL extension, you can open the folder in WSL mode and everything works as if you were running on native linux.

remote-wsl ['node' that it uses] consumes too much cpu power .

Was this page helpful?
0 / 5 - 0 ratings