/cgthreads (Code Generation Threads)
For the latest documentation on Visual Studio 2017, see Visual Studio 2017 Documentation.
For the latest documentation on Visual Studio 2017, see -cgthreads (Code Generation Threads) on docs.microsoft.com. Sets number of cl.exe threads to use for optimization and code generation.
The maximum number of threads for cl.exe to use, in the range 1 to 8.
The /cgthreads option specifies the maximum number of threads cl.exe uses in parallel for the optimization and code generation phases of compilation. Notice that there can be no space between /cgthreads and the
number argument. By default, cl.exe uses four threads, as if /cgthreads4 were specified. If more processor cores are available, a larger
number value can improve build times. This option is especially useful when it's combined with /GL (Whole Program Optimization).
Multiple levels of parallelism can be specified for a build. The msbuild.exe switch /maxcpucount specifies the number of MSBuild processes that can be run in parallel. The /MP (Build with Multiple Processes) compiler flag specifies the number of cl.exe processes that simultaneously compile the source files. The /cgthreads option specifies the number of threads used by each cl.exe process. Because the processor can only run as many threads at the same time as there are processor cores, it's not useful to specify larger values for all of these options at the same time, and it can be counterproductive. For more information about how to build projects in parallel, see Building Multiple Projects in Parallel.
Open the project's Property Pages dialog box. For details, see Working with Project Properties.
Select the Configuration Properties, C/C++ folder.
Select the Command Line property page.
Modify the Additional Options property to include /cgthreads
Nis a value from 1 to 8, and then select OK.
- See AdditionalOptions.