diff options
author | Kyle Edwards <kyle.edwards@kitware.com> | 2021-07-27 15:45:57 (GMT) |
---|---|---|
committer | Kyle Edwards <kyle.edwards@kitware.com> | 2021-07-27 15:45:57 (GMT) |
commit | 3e42bf3e0575d8e203405d95fd24065ea6b70495 (patch) | |
tree | c094de26a076bb619ce3f96c0b51c6e038a41b26 | |
parent | f7cf69e34a1607e8ea2b6d10fef6a6058377c24e (diff) | |
download | CMake-3e42bf3e0575d8e203405d95fd24065ea6b70495.zip CMake-3e42bf3e0575d8e203405d95fd24065ea6b70495.tar.gz CMake-3e42bf3e0575d8e203405d95fd24065ea6b70495.tar.bz2 |
CMakePresets: Check presets with their own file version
06e6981 added support for optional binaryDir and generator, but
use the dependent preset's file version instead of the current
preset's file version. Check presets with their own file version
instead of their dependent's file version.
Fixes: #22428
-rw-r--r-- | Source/cmCMakePresetsFile.cxx | 10 | ||||
-rw-r--r-- | Tests/RunCMake/CMakePresets/RunCMakeTest.cmake | 1 | ||||
-rw-r--r-- | Tests/RunCMake/CMakePresets/V2InheritV3Optional.cmake | 0 | ||||
-rw-r--r-- | Tests/RunCMake/CMakePresets/V2InheritV3Optional.json.in | 8 | ||||
-rw-r--r-- | Tests/RunCMake/CMakePresets/V2InheritV3OptionalUser.json.in | 11 |
5 files changed, 25 insertions, 5 deletions
diff --git a/Source/cmCMakePresetsFile.cxx b/Source/cmCMakePresetsFile.cxx index fd578fa..538b668 100644 --- a/Source/cmCMakePresetsFile.cxx +++ b/Source/cmCMakePresetsFile.cxx @@ -78,7 +78,8 @@ void InheritVector(std::vector<T>& child, const std::vector<T>& parent) template <class T> ReadFileResult VisitPreset( T& preset, std::map<std::string, cmCMakePresetsFile::PresetPair<T>>& presets, - std::map<std::string, CycleStatus> cycleStatus, int version) + std::map<std::string, CycleStatus> cycleStatus, + const cmCMakePresetsFile& file) { switch (cycleStatus[preset.Name]) { case CycleStatus::InProgress: @@ -108,7 +109,7 @@ ReadFileResult VisitPreset( return ReadFileResult::USER_PRESET_INHERITANCE; } - auto result = VisitPreset(parentPreset, presets, cycleStatus, version); + auto result = VisitPreset(parentPreset, presets, cycleStatus, file); if (result != ReadFileResult::READ_OK) { return result; } @@ -128,7 +129,7 @@ ReadFileResult VisitPreset( preset.ConditionEvaluator.reset(); } - CHECK_OK(preset.VisitPresetAfterInherit(version)) + CHECK_OK(preset.VisitPresetAfterInherit(file.GetVersion(preset))) cycleStatus[preset.Name] = CycleStatus::Verified; return ReadFileResult::READ_OK; @@ -146,8 +147,7 @@ ReadFileResult ComputePresetInheritance( for (auto& it : presets) { auto& preset = it.second.Unexpanded; - auto result = - VisitPreset<T>(preset, presets, cycleStatus, file.GetVersion(preset)); + auto result = VisitPreset<T>(preset, presets, cycleStatus, file); if (result != ReadFileResult::READ_OK) { return result; } diff --git a/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake b/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake index 31bd8a4..c31a645 100644 --- a/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake +++ b/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake @@ -260,6 +260,7 @@ unset(CMakePresets_FILE) run_cmake_presets(GoodUserOnly) run_cmake_presets(GoodUserFromMain) run_cmake_presets(GoodUserFromUser) +run_cmake_presets(V2InheritV3Optional) # Test CMakeUserPresets.json errors run_cmake_presets(UserDuplicateInUser) diff --git a/Tests/RunCMake/CMakePresets/V2InheritV3Optional.cmake b/Tests/RunCMake/CMakePresets/V2InheritV3Optional.cmake new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/V2InheritV3Optional.cmake diff --git a/Tests/RunCMake/CMakePresets/V2InheritV3Optional.json.in b/Tests/RunCMake/CMakePresets/V2InheritV3Optional.json.in new file mode 100644 index 0000000..957b157 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/V2InheritV3Optional.json.in @@ -0,0 +1,8 @@ +{ + "version": 3, + "configurePresets": [ + { + "name": "default" + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/V2InheritV3OptionalUser.json.in b/Tests/RunCMake/CMakePresets/V2InheritV3OptionalUser.json.in new file mode 100644 index 0000000..f18c1b9 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/V2InheritV3OptionalUser.json.in @@ -0,0 +1,11 @@ +{ + "version": 2, + "configurePresets": [ + { + "name": "V2InheritV3Optional", + "inherits": "default", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build" + } + ] +} |