# Generic way to enable cpp files multiprocessing for any project (MSBuild)

**URL:** https://discourse.cmake.org/t/generic-way-to-enable-cpp-files-multiprocessing-for-any-project-msbuild/15422
**Category:** Usage
**Tags:** os:windows
**Created:** [December 24, 2025, 8:41am UTC](https://discourse.cmake.org/t/generic-way-to-enable-cpp-files-multiprocessing-for-any-project-msbuild/15422 "2025-12-24T08:41:43Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Andrej730](https://discourse.cmake.org/user_avatar/discourse.cmake.org/andrej730/32/5752_2.png) [@Andrej730](https://discourse.cmake.org/u/Andrej730)
#### Post date: [December 24, 2025, 8:41am UTC](https://discourse.cmake.org/t/generic-way-to-enable-cpp-files-multiprocessing-for-any-project-msbuild/15422/1 "2025-12-24T08:41:43Z")

</div>

`-j` flag in `cmake --build` enabled multiprocessing for different Visual Studio projects (e.g. different targets), but typically user needs multiprocessing for different `.cpp` files and projects, not just projects.

Providing `/MP` flag to `cl` resolves that. It can be provided using `CXXFLAGS` environment variable, but some cmake project might override it - it’s a bad practice, but it does happen. Alternative is to chage cmake file, but it’s also undesirable.

So the solution would be to provide it somehow to `--build` command. Providing it as `cmake --build . -v -- /p:MultiProcessorCompilation=true` doesn’t seems to work (though there are reports that it did worked before or works in some cases, [see](https://stackoverflow.com/questions/17702829/how-to-enable-multiprocessor-compilation-in-call-to-msbuild-but-not-in-visual-st)). Which is kind of odd, since `/p:WholeProgramOptimization=true` works fine and sets `/GL` flag correctly. Not sure if there’s some other property to pass additional options to `cl`.

As a workaround I’ve found `/p:UseMultiToolTask=true` - by default msbuild starts a single `cl` process for each project passing multiple `.cpp` files to it. But with this option, it creates separate `cl` process for each `.cpp` file. By default it creates them as many as there are effective processors on the computer. It can be adjusted using `/p:CL_MPCount=N`.

So the ultimate command for enabling multiprocessing seems to be this. It will build multiple projects and .cpp files in parallel, limiting the number of processes across all projects.

```auto
cmake --build . -- /p:UseMultiToolTask=true /m /p:EnforceProcessCountAcrossBuilds=true

```

Questions:

1. Is this the way to do it? Are there any downsides to `UseMultiToolTask` vs `/MP`?
2. Is there a generic way to provide some `cl` option using msbuild arguments?
3. Is there a way to set `/MP` from msbuild arguments?
