| 1056 | } |
| 1057 | |
| 1058 | bool cmCMakePresetsGraph::ReadProjectPresetsInternal(bool allowNoFiles) |
| 1059 | { |
| 1060 | bool haveOneFile = false; |
| 1061 | |
| 1062 | File* file; |
| 1063 | std::string filename = GetUserFilename(this->SourceDir); |
| 1064 | std::vector<File*> inProgressFiles; |
| 1065 | if (cmSystemTools::FileExists(filename)) { |
| 1066 | if (!this->ReadJSONFile(filename, RootType::User, ReadReason::Root, |
| 1067 | inProgressFiles, file, this->errors)) { |
| 1068 | return false; |
| 1069 | } |
| 1070 | haveOneFile = true; |
| 1071 | } else { |
| 1072 | filename = GetFilename(this->SourceDir); |
| 1073 | if (cmSystemTools::FileExists(filename)) { |
| 1074 | if (!this->ReadJSONFile(filename, RootType::Project, ReadReason::Root, |
| 1075 | inProgressFiles, file, this->errors)) { |
| 1076 | return false; |
| 1077 | } |
| 1078 | haveOneFile = true; |
| 1079 | } |
| 1080 | } |
| 1081 | assert(inProgressFiles.empty()); |
| 1082 | |
| 1083 | if (!haveOneFile) { |
| 1084 | if (allowNoFiles) { |
| 1085 | return true; |
| 1086 | } |
| 1087 | cmCMakePresetsErrors::FILE_NOT_FOUND(filename, &this->parseState); |
| 1088 | return false; |
| 1089 | } |
| 1090 | |
| 1091 | bool result = ComputePresetInheritance(this->ConfigurePresets, *this) && |
| 1092 | ComputePresetInheritance(this->BuildPresets, *this) && |
| 1093 | ComputePresetInheritance(this->TestPresets, *this) && |
| 1094 | ComputePresetInheritance(this->PackagePresets, *this) && |
| 1095 | ComputePresetInheritance(this->WorkflowPresets, *this); |
| 1096 | if (!result) { |
| 1097 | return false; |
| 1098 | } |
| 1099 | |
| 1100 | for (auto& it : this->ConfigurePresets) { |
| 1101 | if (!ExpandMacros(*this, it.second.Unexpanded, it.second.Expanded)) { |
| 1102 | cmCMakePresetsErrors::INVALID_MACRO_EXPANSION(it.first, |
| 1103 | &this->parseState); |
| 1104 | return false; |
| 1105 | } |
| 1106 | } |
| 1107 | |
| 1108 | for (auto& it : this->BuildPresets) { |
| 1109 | if (!it.second.Unexpanded.Hidden) { |
| 1110 | auto const configurePreset = |
| 1111 | this->ConfigurePresets.find(it.second.Unexpanded.ConfigurePreset); |
| 1112 | if (configurePreset == this->ConfigurePresets.end()) { |
| 1113 | cmCMakePresetsErrors::INVALID_CONFIGURE_PRESET(it.first, |
| 1114 | &this->parseState); |
| 1115 | return false; |
no test coverage detected