Build on WSL2 by Visual Studio 2022 + CMake is slow

John 76 Reputation points
2022-04-28T23:04:43.437+00:00

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

197494-image.png

But seems the change only is not helpful.
Then, I checked the cmake documentation: https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html
There is

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

Seems it's disallowed, why?
197517-image.png

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.
5,247 questions
{count} votes

Accepted answer
  1. Paul Maybee 76 Reputation points
    2022-05-02T16:18:45.223+00:00

    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
    }
    ]

    -Paul


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.