target_sources(): Enforce stricter requirements for FILE_SET name

Fixes: #23286
This commit is contained in:
Kyle Edwards
2022-03-03 10:15:08 -05:00
parent 04a7200c75
commit b357d334fc
8 changed files with 30 additions and 4 deletions

View File

@@ -215,9 +215,10 @@ bool TargetSourcesImpl::HandleFileSetMode(
auto fileSet = this->Target->GetOrCreateFileSet(args.FileSet, type);
if (fileSet.second) {
if (!isDefault) {
if (args.FileSet[0] >= 'A' && args.FileSet[0] <= 'Z') {
this->SetError(
"Non-default file set name must not start with a capital letter");
if (!cmFileSet::IsValidName(args.FileSet)) {
this->SetError("Non-default file set name must contain only letters, "
"numbers, and underscores, and must not start with a "
"capital letter or underscore");
return false;
}
}