diff --git a/CHANGELOG.md b/CHANGELOG.md index 7fc1cbefd..dc66a970b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## 1.9.1 Bug fixes: - Fix presets using conditions with macros and inheritance. [#2185](https://github.com/microsoft/vscode-cmake-tools/issues/2185) +- Don't add `-j` argument when `cmake.parallelJobs` is set to `1`. [#2187](https://github.com/microsoft/vscode-cmake-tools/issues/2187) [@mark-ulrich](https://github.com/mark-ulrich) ## 1.9.0 Improvements: diff --git a/docs/cmake-settings.md b/docs/cmake-settings.md index 6caf64ba6..27891ea2b 100644 --- a/docs/cmake-settings.md +++ b/docs/cmake-settings.md @@ -29,7 +29,7 @@ Options that support substitution, in the table below, allow variable references | `cmake.installPrefix` | If specified, sets a value for `CMAKE_INSTALL_PREFIX` when running CMake configure. If not set, no value will be passed.
If `CMAKE_INSTALL_PREFIX` is set via `cmake.configureArgs` or `cmake.configureSettings`, `cmake.installPrefix` will be ignored.| `null` (no value specified) | yes | | `cmake.loggingLevel` | A string setting that specifies how much output CMake Tools produces in its output channel. Set to one of `"trace"`, `"debug"`, `"info"`, `"note"`, `"warning"`, `"error"`, or `"fatal"`. `"trace"` is the most verbose.

Regardless of the logging level, CMake Tools writes all levels of logging to the CMake Tools log file. This file is useful if you need to [troubleshoot CMake Tools](troubleshoot.md) | `"info"` | no | | `cmake.mingwSearchDirs`| List of paths to search for a MinGW installation. This means that GCC does not need to be on your `$PATH` for it to be found via kit scanning. | ["C:\\MinGW"] (Search in C:\MinGW for a MinGW installation) | no | -| `cmake.parallelJobs` | Specify the number of jobs run in parallel during the build. | | no | +| `cmake.parallelJobs` | Specify the number of jobs run in parallel during the build. Using the value `1` will disable build parallelism. | | no | | `cmake.preferredGenerators` | A list of strings of generator names to try, in order, when configuring a CMake project for the first time. | | no | | `cmake.saveBeforeBuild` | If `true` (the default), saves open text documents when build or configure is invoked before running CMake. | `true` | no | | `cmake.sourceDirectory` | Directory where the root `CMakeLists.txt` is stored. | `${workspaceFolder}` | yes | diff --git a/package.nls.json b/package.nls.json index b97bac724..4f8b72b5e 100644 --- a/package.nls.json +++ b/package.nls.json @@ -75,7 +75,7 @@ "cmake-tools.configuration.cmake.configureArgs.description": "Additional arguments to pass to CMake when configuring.", "cmake-tools.configuration.cmake.buildArgs.description": "Additional arguments to pass to CMake when building.", "cmake-tools.configuration.cmake.buildToolArgs.description": "Additional arguments to pass to the underlying build tool when building.", - "cmake-tools.configuration.cmake.parallelJobs.description": "The number of parallel build jobs. Use zero to automatically detect the number of CPUs.", + "cmake-tools.configuration.cmake.parallelJobs.description": "The number of parallel build jobs. Use zero to automatically detect the number of CPUs. Setting this to 1 will disable build parallelism.", "cmake-tools.configuration.cmake.ctestPath.description": "Path to CTest executable. If null, will be inferred from cmake.cmakePath (recommended to leave null).", "cmake-tools.configuration.cmake.ctest.parallelJobs.description": "The number of parallel test jobs. Use zero to use the value of cmake.parallelJobs.", "cmake-tools.configuration.cmake.parseBuildDiagnostics.description": "Parse compiler output for warnings and errors.", diff --git a/src/drivers/driver.ts b/src/drivers/driver.ts index 1abf95a15..0e2bef51b 100644 --- a/src/drivers/driver.ts +++ b/src/drivers/driver.ts @@ -1564,19 +1564,22 @@ export abstract class CMakeDriver implements vscode.Disposable { const buildArgs: string[] = this.config.buildArgs.slice(0); const buildToolArgs: string[] = ['--'].concat(this.config.buildToolArgs); - // Prefer using CMake's build options to set parallelism over tool-specific switches. - // The feature is not available until version 3.14. - if (this.cmake.version && util.versionGreaterOrEquals(this.cmake.version, util.parseVersion('3.14.0'))) { - buildArgs.push('-j'); - if (this.config.numJobs) { - buildArgs.push(this.config.numJobs.toString()); - } - } else { - if (gen) { - if (/(Unix|MinGW) Makefiles|Ninja/.test(gen) && targets !== ['clean']) { - buildToolArgs.push('-j', this.config.numJobs.toString()); - } else if (/Visual Studio/.test(gen) && targets !== ['clean']) { - buildToolArgs.push('/maxcpucount:' + this.config.numJobs.toString()); + // Only add '-j' argument if parallelJobs > 1 + if (this.config.numJobs > 1) { + // Prefer using CMake's build options to set parallelism over tool-specific switches. + // The feature is not available until version 3.14. + if (this.cmake.version && util.versionGreaterOrEquals(this.cmake.version, util.parseVersion('3.14.0'))) { + buildArgs.push('-j'); + if (this.config.numJobs) { + buildArgs.push(this.config.numJobs.toString()); + } + } else { + if (gen) { + if (/(Unix|MinGW) Makefiles|Ninja/.test(gen) && targets !== ['clean']) { + buildToolArgs.push('-j', this.config.numJobs.toString()); + } else if (/Visual Studio/.test(gen) && targets !== ['clean']) { + buildToolArgs.push('/maxcpucount:' + this.config.numJobs.toString()); + } } } }