# How can I enable "Build in Parallel" on VS for a cutom build tool?

**URL:** https://discourse.cmake.org/t/how-can-i-enable-build-in-parallel-on-vs-for-a-cutom-build-tool/6533
**Category:** Usage
**Tags:** gen:vs
**Created:** [September 20, 2022, 3:31pm UTC](https://discourse.cmake.org/t/how-can-i-enable-build-in-parallel-on-vs-for-a-cutom-build-tool/6533 "2022-09-20T15:31:49Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![clearissimple](https://discourse.cmake.org/user_avatar/discourse.cmake.org/clearissimple/32/2786_2.png) [@clearissimple](https://discourse.cmake.org/u/clearissimple)
#### Post date: [September 20, 2022, 3:31pm UTC](https://discourse.cmake.org/t/how-can-i-enable-build-in-parallel-on-vs-for-a-cutom-build-tool/6533/1 "2022-09-20T15:31:49Z")

</div>

Is there a way to set the “Build In Parallel” property to **Yes** during cmake configuration of a visual studio project?  
The build steps are added with add\_custom\_command.

 ![image](https://discourse.cmake.org/uploads/default/original/2X/b/bfedb6f6911b2f36bbc48ac7ad12197d5e33068a.png)

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [September 21, 2022, 12:57am UTC](https://discourse.cmake.org/t/how-can-i-enable-build-in-parallel-on-vs-for-a-cutom-build-tool/6533/2 "2022-09-21T00:57:09Z")

</div>

No, I don’t think there’s currently a way to control this. What is it in parallel to? Other projects or targets/commands within the project?

---

<div class="post-metadata">

### Author: ![clearissimple](https://discourse.cmake.org/user_avatar/discourse.cmake.org/clearissimple/32/2786_2.png) [@clearissimple](https://discourse.cmake.org/u/clearissimple)
#### Post date: [September 21, 2022, 8:31am UTC](https://discourse.cmake.org/t/how-can-i-enable-build-in-parallel-on-vs-for-a-cutom-build-tool/6533/3 "2022-09-21T08:31:32Z")

</div>

Hi, it’s in parallel to other targets/commands.  
In my case, the tool generates several headers, which could all be done in parallel, but the tool is run sequentially one by one. With the “Build in Parallel” option enabled, multiple tool invocations will be run in parallel.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [September 21, 2022, 1:04pm UTC](https://discourse.cmake.org/t/how-can-i-enable-build-in-parallel-on-vs-for-a-cutom-build-tool/6533/4 "2022-09-21T13:04:22Z")

</div>

I don’t think there’s a way to do that right now. I think you could attach a custom target to each custom command (then instead of listing the header in the library/executable target, add a dependency to the custom target(s)) and that should free them up to run concurrently with each other. The generated sources won’t be in the library/executable list in the IDE anymore though.

---

<div class="post-metadata">

### Author: ![serge](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/s/5f8ce5/32.png) [@serge](https://discourse.cmake.org/u/serge)
#### Post date: [September 22, 2022, 3:33pm UTC](https://discourse.cmake.org/t/how-can-i-enable-build-in-parallel-on-vs-for-a-cutom-build-tool/6533/5 "2022-09-22T15:33:56Z")

</div>

Just a remark:  
As far as I understand, the “build in parallel” property for regular target is not supported by cmake neither.  
You can achieve it by adding /MP option to the compiler options but cmake does not handle it  
directly anyway.

---

<div class="post-metadata">

### Author: ![clearissimple](https://discourse.cmake.org/user_avatar/discourse.cmake.org/clearissimple/32/2786_2.png) [@clearissimple](https://discourse.cmake.org/u/clearissimple)
#### Post date: [September 30, 2022, 11:16am UTC](https://discourse.cmake.org/t/how-can-i-enable-build-in-parallel-on-vs-for-a-cutom-build-tool/6533/6 "2022-09-30T11:16:02Z")

</div>

I can get the behavior I want by performing a substitution in the generated `vcxproj` file.  
`(Get-Content custom_tool_use.vcxproj) -replace '</ItemDefinitionGroup>', '<CustomBuild> <BuildInParallel>true</BuildInParallel> </CustomBuild> </ItemDefinitionGroup>' | Out-File custom_tool_use.vcxproj`

Is it possible to have cmake execute this after `vcxproj` files have been generated?

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [October 7, 2022, 6:08pm UTC](https://discourse.cmake.org/t/how-can-i-enable-build-in-parallel-on-vs-for-a-cutom-build-tool/6533/7 "2022-10-07T18:08:15Z")

</div>

Not today, but it sounds like something that CMake can generate with an appropriate setting. Please file [a feature request](https://gitlab.kitware.com/cmake/cmake/-/issues/new).
