diff options
author | Carsten Rudolph <18394207+crud89@users.noreply.github.com> | 2022-01-22 09:12:25 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2022-01-22 11:35:41 (GMT) |
commit | 9aa7831f05e924830848822aecdb43aa7261bc11 (patch) | |
tree | 8764b548493b8ce44b29310cae62d53ef314649b /Source | |
parent | b2f8f0bb87b3b49a39d1db4333bffc5405166245 (diff) | |
download | CMake-9aa7831f05e924830848822aecdb43aa7261bc11.zip CMake-9aa7831f05e924830848822aecdb43aa7261bc11.tar.gz CMake-9aa7831f05e924830848822aecdb43aa7261bc11.tar.bz2 |
Presets: add resolve packages setting to build presets.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmCMakePresetsGraph.cxx | 3 | ||||
-rw-r--r-- | Source/cmCMakePresetsGraph.h | 3 | ||||
-rw-r--r-- | Source/cmCMakePresetsGraphReadJSONBuildPresets.cxx | 35 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudio10Generator.cxx | 4 | ||||
-rw-r--r-- | Source/cmake.cxx | 4 |
5 files changed, 48 insertions, 1 deletions
diff --git a/Source/cmCMakePresetsGraph.cxx b/Source/cmCMakePresetsGraph.cxx index 58dca36..f8e71c9 100644 --- a/Source/cmCMakePresetsGraph.cxx +++ b/Source/cmCMakePresetsGraph.cxx @@ -724,6 +724,9 @@ cmCMakePresetsGraph::BuildPreset::VisitPresetInherit( InheritOptionalValue(preset.CleanFirst, parent.CleanFirst); InheritOptionalValue(preset.Verbose, parent.Verbose); InheritVector(preset.NativeToolOptions, parent.NativeToolOptions); + if (!preset.ResolvePackageReferences) { + preset.ResolvePackageReferences = parent.ResolvePackageReferences; + } return ReadFileResult::READ_OK; } diff --git a/Source/cmCMakePresetsGraph.h b/Source/cmCMakePresetsGraph.h index 02c506f..5159b60 100644 --- a/Source/cmCMakePresetsGraph.h +++ b/Source/cmCMakePresetsGraph.h @@ -14,6 +14,8 @@ #include <cm/optional> +enum class PackageResolveMode; + class cmCMakePresetsGraph { public: @@ -182,6 +184,7 @@ public: cm::optional<bool> CleanFirst; cm::optional<bool> Verbose; std::vector<std::string> NativeToolOptions; + cm::optional<PackageResolveMode> ResolvePackageReferences; ReadFileResult VisitPresetInherit(const Preset& parent) override; ReadFileResult VisitPresetAfterInherit(int /* version */) override; diff --git a/Source/cmCMakePresetsGraphReadJSONBuildPresets.cxx b/Source/cmCMakePresetsGraphReadJSONBuildPresets.cxx index ef605d1..eefe2fe 100644 --- a/Source/cmCMakePresetsGraphReadJSONBuildPresets.cxx +++ b/Source/cmCMakePresetsGraphReadJSONBuildPresets.cxx @@ -12,6 +12,7 @@ #include <cm3p/json/value.h> +#include "cmBuildOptions.h" #include "cmCMakePresetsGraph.h" #include "cmCMakePresetsGraphInternal.h" #include "cmJSONHelpers.h" @@ -20,6 +21,37 @@ namespace { using ReadFileResult = cmCMakePresetsGraph::ReadFileResult; using BuildPreset = cmCMakePresetsGraph::BuildPreset; +ReadFileResult PackageResolveModeHelper(cm::optional<PackageResolveMode>& out, + const Json::Value* value) +{ + if (!value) { + out = cm::nullopt; + return ReadFileResult::READ_OK; + } + + if (!value->isString()) { + return ReadFileResult::INVALID_PRESET; + } + + if (value->asString() == "on") { + out = PackageResolveMode::Force; + } else if (value->asString() == "off") { + out = PackageResolveMode::Disable; + } else if (value->asString() == "only") { + out = PackageResolveMode::OnlyResolve; + } else { + return ReadFileResult::INVALID_PRESET; + } + + return ReadFileResult::READ_OK; +} + +std::function<ReadFileResult(BuildPreset&, const Json::Value*)> const + ResolvePackageReferencesHelper = + [](BuildPreset& out, const Json::Value* value) -> ReadFileResult { + return PackageResolveModeHelper(out.ResolvePackageReferences, value); +}; + auto const BuildPresetHelper = cmJSONObjectHelper<BuildPreset, ReadFileResult>( ReadFileResult::READ_OK, ReadFileResult::INVALID_PRESET, false) @@ -59,7 +91,8 @@ auto const BuildPresetHelper = .Bind("nativeToolOptions"_s, &BuildPreset::NativeToolOptions, cmCMakePresetsGraphInternal::PresetVectorStringHelper, false) .Bind("condition"_s, &BuildPreset::ConditionEvaluator, - cmCMakePresetsGraphInternal::PresetConditionHelper, false); + cmCMakePresetsGraphInternal::PresetConditionHelper, false) + .Bind("resolvePackageReferences"_s, ResolvePackageReferencesHelper, false); } namespace cmCMakePresetsGraphInternal { diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 6b060a6..e9824fb 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -724,6 +724,10 @@ void cmGlobalVisualStudio10Generator::Generate() /* clang-format on */ lg->IssueMessage(MessageType::WARNING, e.str()); } + if (cmValue cached = this->CMakeInstance->GetState()->GetCacheEntryValue( + "CMAKE_VS_NUGET_PACKAGE_RESTORE")) { + this->CMakeInstance->MarkCliAsUsed("CMAKE_VS_NUGET_PACKAGE_RESTORE"); + } } void cmGlobalVisualStudio10Generator::EnableLanguage( diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 2361ce2..8393cd3 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -3331,6 +3331,10 @@ int cmake::Build(int jobs, std::string dir, std::vector<std::string> targets, buildOptions.Clean = *expandedPreset->CleanFirst; } + if (expandedPreset->ResolvePackageReferences) { + buildOptions.ResolveMode = *expandedPreset->ResolvePackageReferences; + } + if (!verbose && expandedPreset->Verbose) { verbose = *expandedPreset->Verbose; } |