| 207 | } |
| 208 | |
| 209 | bool TargetSourcesImpl::HandleOneFileSet( |
| 210 | std::string const& scope, std::vector<std::string> const& content) |
| 211 | { |
| 212 | std::vector<std::string> unparsed; |
| 213 | auto args = FileSetArgsParser.Parse(content, &unparsed); |
| 214 | |
| 215 | if (!unparsed.empty()) { |
| 216 | this->SetError( |
| 217 | cmStrCat("Unrecognized keyword: \"", unparsed.front(), '"')); |
| 218 | return false; |
| 219 | } |
| 220 | |
| 221 | if (args.FileSet.empty()) { |
| 222 | this->SetError("FILE_SET must not be empty"); |
| 223 | return false; |
| 224 | } |
| 225 | |
| 226 | if (this->Target->GetType() == cmStateEnums::UTILITY) { |
| 227 | this->SetError("FILE_SETs may not be added to custom targets"); |
| 228 | return false; |
| 229 | } |
| 230 | if (this->Target->IsFrameworkOnApple()) { |
| 231 | this->SetError("FILE_SETs may not be added to FRAMEWORK targets"); |
| 232 | return false; |
| 233 | } |
| 234 | |
| 235 | bool const isDefault = args.Type == args.FileSet || |
| 236 | (args.Type.empty() && args.FileSet[0] >= 'A' && args.FileSet[0] <= 'Z'); |
| 237 | std::string type = isDefault ? args.FileSet : args.Type; |
| 238 | |
| 239 | cmFileSetVisibility visibility = |
| 240 | cmFileSetVisibilityFromName(scope, this->Makefile); |
| 241 | |
| 242 | auto fileSet = |
| 243 | this->Target->GetOrCreateFileSet(args.FileSet, type, visibility); |
| 244 | if (fileSet.second) { |
| 245 | if (!isDefault) { |
| 246 | if (!cmFileSet::IsValidName(args.FileSet)) { |
| 247 | this->SetError("Non-default file set name must contain only letters, " |
| 248 | "numbers, and underscores, and must not start with a " |
| 249 | "capital letter or underscore"); |
| 250 | return false; |
| 251 | } |
| 252 | } |
| 253 | if (type.empty()) { |
| 254 | this->SetError("Must specify a TYPE when creating file set"); |
| 255 | return false; |
| 256 | } |
| 257 | if (type != "HEADERS"_s && type != "CXX_MODULES"_s) { |
| 258 | this->SetError( |
| 259 | R"(File set TYPE may only be "HEADERS" or "CXX_MODULES")"); |
| 260 | return false; |
| 261 | } |
| 262 | |
| 263 | if (cmFileSetVisibilityIsForSelf(visibility) && |
| 264 | this->Target->GetType() == cmStateEnums::INTERFACE_LIBRARY && |
| 265 | !this->Target->IsImported()) { |
| 266 | if (type == "CXX_MODULES"_s) { |
no test coverage detected