question

John-6058 avatar image
0 Votes"
John-6058 asked John-6058 commented

Build on WSL2 by Visual Studio 2022 + CMake is slow


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.


vs-general
image.png (12.5 KiB)
image.png (63.2 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

PaulMaybee-3038 avatar image
0 Votes"
PaulMaybee-3038 answered John-6058 commented

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

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks it works.

0 Votes 0 ·