Skip to content

Don't specify -j option when parallel builds is set to 1 #1958

@MGraefe

Description

@MGraefe

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 do cmake --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

  • Operating System: Windows 10
  • CMake Version: 3.20.5
  • VSCode Version: 1.57.1
  • CMake Tools Extension Version: 1.7.3
  • Compiler/Toolchain: Visual Studio 2017 AMD64

Metadata

Metadata

Assignees

No one assigned

    Labels

    Feature: configureenhancementan enhancement to the product that is either not present or an improvement to an existing feature

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions