Only generate or modify CMakeUserPresets.json if none existed, or existing was previously generated by conan - #11452
Merged
lasote merged 5 commits intoJun 15, 2022
Conversation
memsharded
reviewed
Jun 14, 2022
Co-authored-by: James <james@conan.io>
jcar87
marked this pull request as ready for review
June 15, 2022 08:33
lasote
approved these changes
Jun 15, 2022
This was referenced Jun 15, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changelog: Bugfix: Fix logic in the generation of
CMakeUserPresets.json- Conan will only generate the file if it did not previously exist, and will modify an existing one if the file was previously generated by conan. ExistingCMakeUserPresets.jsonwill be left untouched otherwise.Docs: conan-io/docs#2591
Description
Before this PR: if
CMakeUserPresets.jsonfile existed next toCMakeLists.txt, but was empty or did not contain theincludesection (or was empty) - the generator would fail.In this PR: conan will only generate
CMakeUserPresets.jsonif the file did not previously exist, or if it existed and was previously generated by conan, which we now identify with an emptyconanmember in thevendorfield (which is reserved by CMake for third-party tooling).Tests
Modified existing test to cover 3 cases:
CMakeUserPresets.jsondid not exist, and is generated with the correct information after generation (this was already what was being tested)CMakeUserPresets.jsonexists but does not have theconanmember in thevendorfieldCMakeUserPresets.jsonexists and it was previously generated by conan (in this case the test also verifies that the correct information is updated).