Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't add '-j' argument if parallelJobs <= 1 #2187

Merged
merged 7 commits into from
Oct 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion docs/cmake-settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.</br>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.</br></br>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 |
Expand Down
2 changes: 1 addition & 1 deletion package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
29 changes: 16 additions & 13 deletions src/drivers/driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
}
}
Expand Down