MCPcopy Create free account
hub / github.com/Kitware/CMake / HandleOneFileSet

Method HandleOneFileSet

Source/cmTargetSourcesCommand.cxx:209–337  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

207}
208
209bool 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) {

Callers 1

HandleFileSetModeMethod · 0.95

Calls 15

JoinMethod · 0.95
GetOrCreateFileSetMethod · 0.80
emplace_backMethod · 0.80
GetVisibilityMethod · 0.80
AddFileEntryMethod · 0.80
AddDirectoryEntryMethod · 0.80
cmStrCatFunction · 0.70

Tested by

no test coverage detected