diff options
author | Brad King <brad.king@kitware.com> | 2022-04-12 14:05:13 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2022-04-12 14:05:26 (GMT) |
commit | f6476ba3a6b13a5323dbcfb8c87acb866b5c9db1 (patch) | |
tree | a845cadd9cc1ec6018b642d1cb529f674a5510f5 /Source/cmTarget.cxx | |
parent | b41f2695bcc4d93e963e20a5d407a01c97164150 (diff) | |
parent | 5fa15ec9f34d69b2a6b1ce08a6102f16c5d7ab9b (diff) | |
download | CMake-f6476ba3a6b13a5323dbcfb8c87acb866b5c9db1.zip CMake-f6476ba3a6b13a5323dbcfb8c87acb866b5c9db1.tar.gz CMake-f6476ba3a6b13a5323dbcfb8c87acb866b5c9db1.tar.bz2 |
Merge topic 'file-set-repr-improvements'
5fa15ec9f3 Help: Document that target_sources defines [INTERFACE_]HEADER_SETS
c5d4812f20 cmTarget: make HEADER_SETS and INTERFACE_HEADER_SETS read-only
05783b168d cmFileSet: store visibility with the fileset
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !7168
Diffstat (limited to 'Source/cmTarget.cxx')
-rw-r--r-- | Source/cmTarget.cxx | 97 |
1 files changed, 42 insertions, 55 deletions
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index e2314e2..5c43bc8 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -1484,37 +1484,14 @@ void cmTarget::StoreProperty(const std::string& prop, ValueType value) BT<std::string>(value, this->impl->Makefile->GetBacktrace())); } } else if (prop == propHEADER_SETS) { - if (value) { - for (auto const& name : cmExpandedList(value)) { - if (!this->GetFileSet(name)) { - this->impl->Makefile->IssueMessage( - MessageType::FATAL_ERROR, - cmStrCat("Header set \"", name, "\" has not yet been created.")); - return; - } - } - } - this->impl->HeaderSetsEntries.clear(); - if (!StringIsEmpty(value)) { - this->impl->HeaderSetsEntries.emplace_back( - value, this->impl->Makefile->GetBacktrace()); - } + this->impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, + "HEADER_SETS property is read-only\n"); + return; } else if (prop == propINTERFACE_HEADER_SETS) { - if (value) { - for (auto const& name : cmExpandedList(value)) { - if (!this->GetFileSet(name)) { - this->impl->Makefile->IssueMessage( - MessageType::FATAL_ERROR, - cmStrCat("Header set \"", name, "\" has not yet been created.")); - return; - } - } - } - this->impl->InterfaceHeaderSetsEntries.clear(); - if (!StringIsEmpty(value)) { - this->impl->InterfaceHeaderSetsEntries.emplace_back( - value, this->impl->Makefile->GetBacktrace()); - } + this->impl->Makefile->IssueMessage( + MessageType::FATAL_ERROR, + "INTERFACE_HEADER_SETS property is read-only\n"); + return; } else { this->impl->Properties.SetProperty(prop, value); } @@ -1680,27 +1657,14 @@ void cmTarget::AppendProperty(const std::string& prop, fileSet->AddFileEntry( BT<std::string>(value, this->impl->Makefile->GetBacktrace())); } else if (prop == "HEADER_SETS") { - for (auto const& name : cmExpandedList(value)) { - if (!this->GetFileSet(name)) { - this->impl->Makefile->IssueMessage( - MessageType::FATAL_ERROR, - cmStrCat("Header set \"", name, "\" has not yet been created.")); - return; - } - } - this->impl->HeaderSetsEntries.emplace_back( - value, this->impl->Makefile->GetBacktrace()); + this->impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, + "HEADER_SETS property is read-only\n"); + return; } else if (prop == "INTERFACE_HEADER_SETS") { - for (auto const& name : cmExpandedList(value)) { - if (!this->GetFileSet(name)) { - this->impl->Makefile->IssueMessage( - MessageType::FATAL_ERROR, - cmStrCat("Header set \"", name, "\" has not yet been created.")); - return; - } - } - this->impl->InterfaceHeaderSetsEntries.emplace_back( - value, this->impl->Makefile->GetBacktrace()); + this->impl->Makefile->IssueMessage( + MessageType::FATAL_ERROR, + "INTERFACE_HEADER_SETS property is read-only\n"); + return; } else { this->impl->Properties.AppendProperty(prop, value, asString); } @@ -2125,13 +2089,26 @@ cmValue cmTarget::GetProperty(const std::string& prop) const return cmValue(output); } if (prop == propHEADER_SETS) { + std::vector<std::string> set_names; + for (auto const& file_set : this->impl->FileSets) { + if (cmFileSetVisibilityIsForSelf(file_set.second.GetVisibility())) { + set_names.push_back(file_set.second.GetName()); + } + } static std::string output; - output = cmJoin(this->impl->HeaderSetsEntries, ";"_s); + output = cmJoin(set_names, ";"_s); return cmValue(output); } if (prop == propINTERFACE_HEADER_SETS) { + std::vector<std::string> set_names; + for (auto const& file_set : this->impl->FileSets) { + if (cmFileSetVisibilityIsForInterface( + file_set.second.GetVisibility())) { + set_names.push_back(file_set.second.GetName()); + } + } static std::string output; - output = cmJoin(this->impl->InterfaceHeaderSetsEntries, ";"_s); + output = cmJoin(set_names, ";"_s); return cmValue(output); } } @@ -2429,10 +2406,20 @@ cmFileSet* cmTarget::GetFileSet(const std::string& name) } std::pair<cmFileSet*, bool> cmTarget::GetOrCreateFileSet( - const std::string& name, const std::string& type) + const std::string& name, const std::string& type, cmFileSetVisibility vis) { - auto result = - this->impl->FileSets.emplace(std::make_pair(name, cmFileSet(name, type))); + auto result = this->impl->FileSets.emplace( + std::make_pair(name, cmFileSet(name, type, vis))); + if (result.second) { + if (cmFileSetVisibilityIsForSelf(vis)) { + this->impl->HeaderSetsEntries.emplace_back( + name, this->impl->Makefile->GetBacktrace()); + } + if (cmFileSetVisibilityIsForInterface(vis)) { + this->impl->InterfaceHeaderSetsEntries.emplace_back( + name, this->impl->Makefile->GetBacktrace()); + } + } return std::make_pair(&result.first->second, result.second); } |