-
Notifications
You must be signed in to change notification settings - Fork 461
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 specify -j option when parallel builds is set to 1 #1958
Comments
@MGraefe, thank you for this suggestion. We will address this. |
@MGraefe, a fix for this problem was included in the CMake Tools 1.9.1 release. Upgrade your extension in VSCode and let us know if you encounter any other issues. |
Awesome, thanks to everyone involved! |
Won't omitting it affect Ninja (and maybe other tools) then, where max parallelization is the default, i.e. omitting |
@mikedld, excellent question. I just double checked, the extension will only omit -j when parallel builds is set to 1. If not set, the extension defaults to number of cpus + 2. |
@andreeis, right, so if I'm using Ninja generator and setting |
These kinds of inconsistencies that come by overloading a single value with a special meaning is why I didn't immediately create a PR for this. I think a separate toggle option "specify parallel builds" in addition to the existing option would be the way to go. But I don't feel comfortable adding this as I never worked with this codebase. |
Summary
For CMake builds, the plugin defines the
-j
flag even if parallelism is set to 1 in the settings. This interferes with MSBuild builds, which behave different when-j
is defined. Instead the -j option shouldn't be defined at all when parallelism is set to 1.Elaboration
CMake disables the /MP option from MSVC builds when the -j flag is specified, to avoid overloading the CPU. For Visual Studio / MSBuild builds, the /MP option enables parallel building of source files, while the CMake
-j
option enables parallel compilation of projects. In fact, CMake effectively removes any manually defined /MP flag from the compiler options in case-j
is defined.But I want my project to be compiled with /MP because for me it's much faster then relying on CMake
-j
. With the CMake plugin I can't, because it keeps specifying-j 1
on the command line even if I set the parallelism to 1.It all works fine from command line if I just do
cmake --build .
and I can reproduce the /MP problem when I docmake --build . -j 16
Proposal:
Don't add the -j option at all if parallelism is set to 1. Alternatively add another settings which can be used to completely disable addition of the -j flag.
Platform and Versions
The text was updated successfully, but these errors were encountered: