target_sources(): Prohibit FILE_SET on custom targets

Fixes: #23262
This commit is contained in:
Kyle Edwards
2022-02-28 17:11:53 -05:00
parent 07a7772968
commit ad41c9cd11
6 changed files with 16 additions and 1 deletions

View File

@@ -16,6 +16,7 @@
#include "cmMakefile.h"
#include "cmMessageType.h"
#include "cmPolicies.h"
#include "cmStateTypes.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmTarget.h"
@@ -202,6 +203,11 @@ bool TargetSourcesImpl::HandleFileSetMode(
return false;
}
if (this->Target->GetType() == cmStateEnums::UTILITY) {
this->SetError("FILE_SETs may not be added to custom targets");
return false;
}
bool const isDefault = args.Type == args.FileSet ||
(args.Type.empty() && args.FileSet[0] >= 'A' && args.FileSet[0] <= 'Z');
std::string type = isDefault ? args.FileSet : args.Type;