summaryrefslogtreecommitdiffstats
path: root/Source/cmTargetSourcesCommand.cxx
diff options
context:
space:
mode:
authorKyle Edwards <kyle.edwards@kitware.com>2022-03-03 18:07:10 (GMT)
committerKyle Edwards <kyle.edwards@kitware.com>2022-03-03 19:31:54 (GMT)
commit8c23ecbd93eb86f7316cdeb2cdc561d28ee95de7 (patch)
tree30bfdd7c329ef4226629c32ad6deca399cc51994 /Source/cmTargetSourcesCommand.cxx
parent04a7200c7561509a83c34f2af45b2d091ae59248 (diff)
downloadCMake-8c23ecbd93eb86f7316cdeb2cdc561d28ee95de7.zip
CMake-8c23ecbd93eb86f7316cdeb2cdc561d28ee95de7.tar.gz
CMake-8c23ecbd93eb86f7316cdeb2cdc561d28ee95de7.tar.bz2
target_sources(): Process multiple FILE_SET arguments per block
Fixes: #23287
Diffstat (limited to 'Source/cmTargetSourcesCommand.cxx')
-rw-r--r--Source/cmTargetSourcesCommand.cxx33
1 files changed, 28 insertions, 5 deletions
diff --git a/Source/cmTargetSourcesCommand.cxx b/Source/cmTargetSourcesCommand.cxx
index b425acb..17af789 100644
--- a/Source/cmTargetSourcesCommand.cxx
+++ b/Source/cmTargetSourcesCommand.cxx
@@ -38,6 +38,14 @@ auto const FileSetArgsParser = cmArgumentParser<FileSetArgs>()
.Bind("BASE_DIRS"_s, &FileSetArgs::BaseDirs)
.Bind("FILES"_s, &FileSetArgs::Files);
+struct FileSetsArgs
+{
+ std::vector<std::vector<std::string>> FileSets;
+};
+
+auto const FileSetsArgsParser =
+ cmArgumentParser<FileSetsArgs>().Bind("FILE_SET"_s, &FileSetsArgs::FileSets);
+
class TargetSourcesImpl : public cmTargetPropCommandBase
{
public:
@@ -79,7 +87,7 @@ private:
bool prepend, bool system) override
{
if (!content.empty() && content.front() == "FILE_SET"_s) {
- return this->HandleFileSetMode(scope, content, prepend, system);
+ return this->HandleFileSetMode(scope, content);
}
return this->cmTargetPropCommandBase::PopulateTargetProperties(
scope, content, prepend, system);
@@ -105,8 +113,9 @@ private:
IsInterface isInterfaceContent, CheckCMP0076 checkCmp0076);
bool HandleFileSetMode(const std::string& scope,
- const std::vector<std::string>& content, bool prepend,
- bool system);
+ const std::vector<std::string>& content);
+ bool HandleOneFileSet(const std::string& scope,
+ const std::vector<std::string>& content);
};
std::vector<std::string> TargetSourcesImpl::ConvertToAbsoluteContent(
@@ -186,8 +195,22 @@ std::vector<std::string> TargetSourcesImpl::ConvertToAbsoluteContent(
}
bool TargetSourcesImpl::HandleFileSetMode(
- const std::string& scope, const std::vector<std::string>& content,
- bool /*prepend*/, bool /*system*/)
+ const std::string& scope, const std::vector<std::string>& content)
+{
+ auto args = FileSetsArgsParser.Parse(content);
+
+ for (auto& argList : args.FileSets) {
+ argList.emplace(argList.begin(), "FILE_SET"_s);
+ if (!this->HandleOneFileSet(scope, argList)) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+bool TargetSourcesImpl::HandleOneFileSet(
+ const std::string& scope, const std::vector<std::string>& content)
{
std::vector<std::string> unparsed;
auto args = FileSetArgsParser.Parse(content, &unparsed);