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

set jobs parameter in cmake build presets(#15419) #15422

Merged
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
3 changes: 3 additions & 0 deletions conan/tools/cmake/presets.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from conan.tools.cmake.layout import get_build_folder_custom_vars
from conan.tools.cmake.toolchain.blocks import GenericSystemBlock
from conan.tools.cmake.utils import is_multi_configuration
from conan.tools.build import build_jobs
from conan.tools.microsoft import is_msvc
from conans.client.graph.graph import RECIPE_CONSUMER
from conan.errors import ConanException
Expand Down Expand Up @@ -189,6 +190,8 @@ def _common_preset_fields(conanfile, multiconfig, preset_prefix):
@staticmethod
def _build_preset_fields(conanfile, multiconfig, preset_prefix):
ret = _CMakePresets._common_preset_fields(conanfile, multiconfig, preset_prefix)
build_preset_jobs = build_jobs(conanfile)
ret["jobs"] = build_preset_jobs
return ret

@staticmethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1214,3 +1214,11 @@ def test_avoid_ovewrite_user_cmakepresets():
c.run('install . -g CMakeToolchain', assert_error=True)
assert "Error in generator 'CMakeToolchain': Existing CMakePresets.json not generated" in c.out
assert "Use --output-folder or define a 'layout' to avoid collision" in c.out


def test_presets_njobs():
c = TestClient()
c.save({"conanfile.txt": ""})
c.run('install . -g CMakeToolchain -c tools.build:jobs=42')
presets = json.loads(c.load("CMakePresets.json"))
assert presets["buildPresets"][0]["jobs"] == 42