-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Description
Describe the bug
tools.build:jobs is ignored on Windows with CMake toolchain and MSBUILD (Visual Studio ...) CMake generator.
It seems cmake.py only adds parallelism flags per build tool, and doesn't know how to add them for MSBUILD. However, there is tools.microsoft.msbuild:max_cpu_count which seems to accomplish the same thing but for MSBUILD.
conan/conan/tools/cmake/cmake.py
Lines 16 to 23 in 4744d8e
| # Arguments related to parallel | |
| njobs = build_jobs(conanfile) | |
| if njobs and ("Makefiles" in generator or "Ninja" in generator) and "NMake" not in generator: | |
| args.append("-j{}".format(njobs)) | |
| maxcpucount = conanfile.conf.get("tools.microsoft.msbuild:max_cpu_count", check_type=int) | |
| if maxcpucount is not None and "Visual Studio" in generator: | |
| args.append(f"/m:{maxcpucount}" if maxcpucount > 0 else "/m") |
- Why is this
tools.microsoft.msbuild:max_cpu_countseparate fromtools.build:jobs? - Also, the docs on
tools.build:jobssay "default: max CPUs", but this apparently doesn't apply here, as MSBUILD by default uses no paralellism.
Since CMake 3.12 it's possible to just pass --parallel (-j) to cmake --build itself, instead of to the build tool (after --). You could consider adopting this approach instead, as it should be more portable.
How to reproduce it
For example:
On Windows with Visual Studio:
$ conan install --requires 'abseil/20250814.0' --build='abseil/*' -c:a 'tools.build:jobs=20'
[...]
abseil/20250814.0: Running CMake.build()
abseil/20250814.0: RUN: cmake --build "C:\Users\pep\.conan2\p\b\absei97ce99baaf616\b\build" --config Release
[...]
On Linux with Ninja: (expected behavior)
$ conan install --requires 'abseil/20250814.0' --build='abseil/*' -c:a 'tools.build:jobs=20'
[...]
abseil/20250814.0: Running CMake.build()
abseil/20250814.0: RUN: cmake --build "/home/swdv/.conan2/p/b/absei5aae6cef00263/b/build/Release" -- -j20
[...]
Metadata
Metadata
Assignees
Labels
No labels