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

CMakePresets compatible with schema 2 #11655

Merged
merged 10 commits into from Jul 19, 2022

Conversation

lasote
Copy link
Contributor

@lasote lasote commented Jul 15, 2022

Changelog: Feature: Introduced a new conf tools.cmake.cmaketoolchain.presets:max_schema_version to generate CMakePresets.json and CMakeUserPresets.json compatible with the specified json schema version. The minimum value supported is >=2.
Docs: conan-io/docs#2666

To discuss: Is this an opt-in? or maybe an opt-out to use the "include" schema?

Close #11649
Close #11648

Copy link
Member

@memsharded memsharded left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking good, though the _schema_version is a bit confusing.

conan/tools/cmake/presets.py Outdated Show resolved Hide resolved
# Try to save the CMakeUserPresets.json if layout declared and CMakeLists.txt found
if conanfile.source_folder and conanfile.source_folder != conanfile.generators_folder:
if os.path.exists(os.path.join(conanfile.source_folder, "CMakeLists.txt")):
user_presets_path = os.path.join(conanfile.source_folder, "CMakeUserPresets.json")
if not os.path.exists(user_presets_path):
data = {"version": 4, "include": [preset_path], "vendor": {"conan": dict()}}
data = {"version": _schema_version(conanfile, default=4),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is confusing, the above uses a default of =3, and now a default=4. Not sure what it means.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is because the schema version of the CMakePreset is 3 but the version of the CMakeUserPreset is 4.
Let me do it better.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bit better now?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It still seems a bit confusing, because if user provides schema=3 in the conf, that will be ignored, and generate a schema=2 in the json, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, the user provides a tools.cmake.cmaketoolchain.presets:max_schema_version=3, that won't be ignored and generates a schema=2.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can convert the conf to tools.cmake.cmaketoolchain.presets:v2_schema=True if you prefer, but I thought that we might end with more similar configs in the future.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see, I overlooked it is max_schema_version, not schema_version. Then it makes a bit more sense, yeah.

conan/tools/cmake/presets.py Show resolved Hide resolved
# Try to save the CMakeUserPresets.json if layout declared and CMakeLists.txt found
if conanfile.source_folder and conanfile.source_folder != conanfile.generators_folder:
if os.path.exists(os.path.join(conanfile.source_folder, "CMakeLists.txt")):
user_presets_path = os.path.join(conanfile.source_folder, "CMakeUserPresets.json")
if not os.path.exists(user_presets_path):
data = {"version": 4, "include": [preset_path], "vendor": {"conan": dict()}}
data = {"version": _schema_version(conanfile, default=4),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see, I overlooked it is max_schema_version, not schema_version. Then it makes a bit more sense, yeah.

@franramirez688 franramirez688 merged commit abfe3f6 into conan-io:develop Jul 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[feature] CMakePresets toolchain inclusion [feature] Try to aggregate CMakePresets instead of including them
4 participants