diff options
author | Ben Boeckel <ben.boeckel@kitware.com> | 2023-01-28 03:46:36 (GMT) |
---|---|---|
committer | Ben Boeckel <ben.boeckel@kitware.com> | 2023-01-31 15:07:02 (GMT) |
commit | 91561103dea6831e3f829b4df1bfc03602cdb6c7 (patch) | |
tree | e403baac31cb4c95ccf448d13910554b0459a386 /Source/cmTarget.cxx | |
parent | f644fc8acab04fb7d7dd96648d0f153b12e2936b (diff) | |
download | CMake-91561103dea6831e3f829b4df1bfc03602cdb6c7.zip CMake-91561103dea6831e3f829b4df1bfc03602cdb6c7.tar.gz CMake-91561103dea6831e3f829b4df1bfc03602cdb6c7.tar.bz2 |
cmTarget: refactor INCLUDE_DIRECTORIES usage requirements
Diffstat (limited to 'Source/cmTarget.cxx')
-rw-r--r-- | Source/cmTarget.cxx | 78 |
1 files changed, 47 insertions, 31 deletions
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 8388181..95b0042 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -303,7 +303,6 @@ public: std::set<std::string> SystemIncludeDirectories; cmTarget::LinkLibraryVectorType OriginalLinkLibraries; std::map<std::string, BTs<std::string>> LanguageStandardProperties; - std::vector<BT<std::string>> IncludeDirectoriesEntries; std::map<cmTargetExport const*, std::vector<std::string>> InstallIncludeDirectoriesEntries; std::vector<BT<std::string>> CompileOptionsEntries; @@ -322,6 +321,8 @@ public: std::map<std::string, cmFileSet> FileSets; cmListFileBacktrace Backtrace; + UsageRequirementProperty IncludeDirectories; + FileSetType HeadersFileSets; FileSetType CxxModulesFileSets; FileSetType CxxModuleHeadersFileSets; @@ -357,7 +358,8 @@ public: }; cmTargetInternals::cmTargetInternals() - : HeadersFileSets("HEADERS"_s, "HEADER_DIRS"_s, "HEADER_SET"_s, + : IncludeDirectories("INCLUDE_DIRECTORIES"_s) + , HeadersFileSets("HEADERS"_s, "HEADER_DIRS"_s, "HEADER_SET"_s, "HEADER_DIRS_"_s, "HEADER_SET_"_s, "Header"_s, "The default header set"_s, "Header set"_s, FileSetEntries("HEADER_SETS"_s), @@ -831,8 +833,8 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, if (!this->IsImported()) { // Initialize the INCLUDE_DIRECTORIES property based on the current value // of the same directory property: - cm::append(this->impl->IncludeDirectoriesEntries, - this->impl->Makefile->GetIncludeDirectoriesEntries()); + this->impl->IncludeDirectories.CopyFromDirectory( + this->impl->Makefile->GetIncludeDirectoriesEntries()); { auto const& sysInc = this->impl->Makefile->GetSystemIncludeDirectories(); @@ -1456,7 +1458,7 @@ cmStringRange cmTarget::GetInstallIncludeDirectoriesEntries( cmBTStringRange cmTarget::GetIncludeDirectoriesEntries() const { - return cmMakeRange(this->impl->IncludeDirectoriesEntries); + return cmMakeRange(this->impl->IncludeDirectories.Entries); } cmBTStringRange cmTarget::GetCompileOptionsEntries() const @@ -1640,6 +1642,17 @@ void cmTarget::StoreProperty(const std::string& prop, ValueType value) return; } + UsageRequirementProperty* usageRequirements[] = { + &this->impl->IncludeDirectories, + }; + + for (auto* usageRequirement : usageRequirements) { + if (usageRequirement->Write(this->impl.get(), {}, prop, value, + UsageRequirementProperty::Action::Set)) { + return; + } + } + FileSetType* fileSetTypes[] = { &this->impl->HeadersFileSets, &this->impl->CxxModulesFileSets, @@ -1653,13 +1666,7 @@ void cmTarget::StoreProperty(const std::string& prop, ValueType value) } } - if (prop == propINCLUDE_DIRECTORIES) { - this->impl->IncludeDirectoriesEntries.clear(); - if (value) { - cmListFileBacktrace lfbt = this->impl->Makefile->GetBacktrace(); - this->impl->IncludeDirectoriesEntries.emplace_back(value, lfbt); - } - } else if (prop == propCOMPILE_OPTIONS) { + if (prop == propCOMPILE_OPTIONS) { this->impl->CompileOptionsEntries.clear(); if (value) { cmListFileBacktrace lfbt = this->impl->Makefile->GetBacktrace(); @@ -1832,6 +1839,17 @@ void cmTarget::AppendProperty(const std::string& prop, return; } + UsageRequirementProperty* usageRequirements[] = { + &this->impl->IncludeDirectories, + }; + + for (auto* usageRequirement : usageRequirements) { + if (usageRequirement->Write(this->impl.get(), bt, prop, cmValue(value), + UsageRequirementProperty::Action::Append)) { + return; + } + } + FileSetType* fileSetTypes[] = { &this->impl->HeadersFileSets, &this->impl->CxxModulesFileSets, @@ -1845,12 +1863,7 @@ void cmTarget::AppendProperty(const std::string& prop, } } - if (prop == "INCLUDE_DIRECTORIES") { - if (!value.empty()) { - cmListFileBacktrace lfbt = this->impl->GetBacktrace(bt); - this->impl->IncludeDirectoriesEntries.emplace_back(value, lfbt); - } - } else if (prop == "COMPILE_OPTIONS") { + if (prop == "COMPILE_OPTIONS") { if (!value.empty()) { cmListFileBacktrace lfbt = this->impl->GetBacktrace(bt); this->impl->CompileOptionsEntries.emplace_back(value, lfbt); @@ -2156,10 +2169,10 @@ void cmTarget::FinalizeTargetConfiguration( void cmTarget::InsertInclude(BT<std::string> const& entry, bool before) { - auto position = before ? this->impl->IncludeDirectoriesEntries.begin() - : this->impl->IncludeDirectoriesEntries.end(); - - this->impl->IncludeDirectoriesEntries.insert(position, entry); + this->impl->IncludeDirectories.WriteDirect( + entry, + before ? UsageRequirementProperty::Action::Prepend + : UsageRequirementProperty::Action::Append); } void cmTarget::InsertCompileOption(BT<std::string> const& entry, bool before) @@ -2338,6 +2351,18 @@ cmValue cmTarget::GetProperty(const std::string& prop) const } return cmValue(propertyIter->second.Value); } + + UsageRequirementProperty const* usageRequirements[] = { + &this->impl->IncludeDirectories, + }; + + for (auto const* usageRequirement : usageRequirements) { + auto value = usageRequirement->Read(prop); + if (value.first) { + return value.second; + } + } + if (prop == propLINK_LIBRARIES) { if (this->impl->LinkImplementationPropertyEntries.empty()) { return nullptr; @@ -2379,15 +2404,6 @@ cmValue cmTarget::GetProperty(const std::string& prop) const if (prop == propTYPE) { return cmValue(cmState::GetTargetTypeName(this->GetType())); } - if (prop == propINCLUDE_DIRECTORIES) { - if (this->impl->IncludeDirectoriesEntries.empty()) { - return nullptr; - } - - static std::string output; - output = cmJoin(this->impl->IncludeDirectoriesEntries, ";"); - return cmValue(output); - } if (prop == propCOMPILE_FEATURES) { if (this->impl->CompileFeaturesEntries.empty()) { return nullptr; |