Skip to content

[bug] CMake build preset with Visual Studio spawns MSBuild processes according to tools.build:jobs #19405

@stevenwdv

Description

@stevenwdv

Describe the bug

Conan erroneously passes tools.build:jobs (default CPU count) to the CMake buildPresets execution.jobs property, which CMake forwards to MSBuild as -maxCpuCount (aka /m), causing multiple MSBuild processes to be spawned.

However, this was supposed to be the job of tools.microsoft.msbuild:max_cpu_count. tools.build:jobs is supposed to map to parallelism by the compiler (cl.exe) via the /MP flag, which will cause it to spawn copies of itself when passed multiple source files within a target by MSBuild. This flag is passed via conan_toolchain.cmake.
When using CMake build presets, this means MSBuild's /m and cl.exe's /MP will stack, leading to tools.build:jobs^2 parallelism.

Originally noticed in #19384 (comment).

How to reproduce it

  • conan install on CMake project with Visual Studio generator
  • cmake --preset conan-debug
  • cmake --build --preset conan-debug
    • Will erroneously spawn tools.build:jobs MSBuild processes.
many MSBuild.exe + cl.exe

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions