-
Notifications
You must be signed in to change notification settings - Fork 970
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
CMakePresets compatible with schema 2 #11655
Conversation
There was a problem hiding this 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.
# 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), |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bit better now?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Co-authored-by: James <james@conan.io>
…to feature/presets_schema_2
# 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), |
There was a problem hiding this comment.
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.
Changelog: Feature: Introduced a new conf
tools.cmake.cmaketoolchain.presets:max_schema_version
to generateCMakePresets.json
andCMakeUserPresets.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