Build on WSL2 by Visual Studio 2022 + CMake is slow

John 71 Reputation points

Hi all,

I am trying to build code on WSL2 by Visual Studio 2022 + CMake
It's build-able, run-able, debug-able, just the build time is long and the CPU utilization is pretty low < 20%.

I tried googling, found I need to set the available processor numbers for WSL2 VM


But seems the change only is not helpful.
Then, I checked the cmake documentation:
There is

An optional integer. Equivalent to passing --parallel or -j on the command line.

Seems it's disallowed, why?

How to leverage the multicore CPU? Thank you.

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
3,171 questions
{count} votes

Accepted answer
  1. Paul Maybee 76 Reputation points

    Hi John,

    The "jobs" element is part of the schema for a "buildPresets", not a "configurePresets". Try adding a new build presets section with the "jobs" element. Something like:

    "buildPresets": [
    "name": "parallelBuild",
    "displayName": "Parallel Build",
    "configurePreset": "linux-debug",
    "jobs": 16


0 additional answers

Sort by: Most helpful