diff options
author | Brad King <brad.king@kitware.com> | 2021-03-23 14:33:32 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2021-03-23 14:33:59 (GMT) |
commit | 928f4bda30eafa85b62be98921ae14a724cdc485 (patch) | |
tree | f56f896a7826b03edd3256a4cdc20fab3fe38a3e /Source/cmake.cxx | |
parent | a740e8b311b86d85a15fde03c82e948206b9878e (diff) | |
parent | 8bc5c8961e552a15091b7f4d2c205ce90b8f764f (diff) | |
download | CMake-928f4bda30eafa85b62be98921ae14a724cdc485.zip CMake-928f4bda30eafa85b62be98921ae14a724cdc485.tar.gz CMake-928f4bda30eafa85b62be98921ae14a724cdc485.tar.bz2 |
Merge topic 'cmake-presets-condition'
8bc5c8961e CMakePresets.json: Add the ability to conditionally disable presets
ce6ea7c927 Refactor: Move some common code into separate file
ebbd475e54 Refactor: Move cmCMakePresetsFile::ReadJSON into a separate file
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5919
Diffstat (limited to 'Source/cmake.cxx')
-rw-r--r-- | Source/cmake.cxx | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 55a7feb..a04338f 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -1217,6 +1217,11 @@ void cmake::SetArgs(const std::vector<std::string>& args) "\": Invalid macro expansion")); return; } + if (!expandedPreset->ConditionResult) { + cmSystemTools::Error(cmStrCat("Could not use disabled preset \"", + preset->second.Unexpanded.Name, "\"")); + return; + } if (!this->State->IsCacheLoaded() && !haveBArg) { this->SetHomeOutputDirectory(expandedPreset->BinaryDir); @@ -3164,6 +3169,14 @@ int cmake::Build(int jobs, std::string dir, std::vector<std::string> targets, return 1; } + if (!expandedPreset->ConditionResult) { + cmSystemTools::Error(cmStrCat("Cannot use disabled build preset in ", + this->GetHomeDirectory(), ": \"", + presetName, '"')); + settingsFile.PrintBuildPresetList(); + return 1; + } + auto configurePresetPair = settingsFile.ConfigurePresets.find(expandedPreset->ConfigurePreset); if (configurePresetPair == settingsFile.ConfigurePresets.end()) { |