diff options
author | Sebastian Holtermann <sebholt@xwmw.org> | 2019-05-23 10:52:36 (GMT) |
---|---|---|
committer | Sebastian Holtermann <sebholt@xwmw.org> | 2019-05-23 11:00:33 (GMT) |
commit | 7b4b61a4d38e4c7fe3fe992a6263d8d1f0785858 (patch) | |
tree | f43eaa67777164ce5ba0dda2f381e35260d06b50 | |
parent | 22d58e07e5dc54e113ae7414dea604549b0cfc43 (diff) | |
download | CMake-7b4b61a4d38e4c7fe3fe992a6263d8d1f0785858.zip CMake-7b4b61a4d38e4c7fe3fe992a6263d8d1f0785858.tar.gz CMake-7b4b61a4d38e4c7fe3fe992a6263d8d1f0785858.tar.bz2 |
cmMakefile: Define cmTargetMap type in cmMakefile instead of cmTarget
The `cmTargetMap` type is only used in the context of `cmMakefile`.
Therefore it is the most appropriate place to declare it.
This moves the `cmTarget.h/cmTargets` type definition to
`cmMakefile::cmTargetMap`.
-rw-r--r-- | Source/cmExportLibraryDependenciesCommand.cxx | 3 | ||||
-rw-r--r-- | Source/cmInstallTargetsCommand.cxx | 4 | ||||
-rw-r--r-- | Source/cmMakefile.cxx | 8 | ||||
-rw-r--r-- | Source/cmMakefile.h | 17 | ||||
-rw-r--r-- | Source/cmOutputRequiredFilesCommand.cxx | 3 | ||||
-rw-r--r-- | Source/cmTarget.h | 3 |
6 files changed, 16 insertions, 22 deletions
diff --git a/Source/cmExportLibraryDependenciesCommand.cxx b/Source/cmExportLibraryDependenciesCommand.cxx index 0a0646c..b60a053 100644 --- a/Source/cmExportLibraryDependenciesCommand.cxx +++ b/Source/cmExportLibraryDependenciesCommand.cxx @@ -76,8 +76,7 @@ void cmExportLibraryDependenciesCommand::ConstFinalPass() const std::map<std::string, std::string> libDepsNew; std::map<std::string, std::string> libTypes; for (cmMakefile* local : locals) { - const cmTargets& tgts = local->GetTargets(); - for (auto const& tgt : tgts) { + for (auto const& tgt : local->GetTargets()) { // Get the current target. cmTarget const& target = tgt.second; diff --git a/Source/cmInstallTargetsCommand.cxx b/Source/cmInstallTargetsCommand.cxx index 7e67d4e..ef07e2c 100644 --- a/Source/cmInstallTargetsCommand.cxx +++ b/Source/cmInstallTargetsCommand.cxx @@ -23,7 +23,7 @@ bool cmInstallTargetsCommand::InitialPass(std::vector<std::string> const& args, // Enable the install target. this->Makefile->GetGlobalGenerator()->EnableInstallTarget(); - cmTargets& tgts = this->Makefile->GetTargets(); + cmMakefile::cmTargetMap& tgts = this->Makefile->GetTargets(); std::vector<std::string>::const_iterator s = args.begin(); ++s; std::string runtime_dir = "/bin"; @@ -38,7 +38,7 @@ bool cmInstallTargetsCommand::InitialPass(std::vector<std::string> const& args, runtime_dir = *s; } else { - cmTargets::iterator ti = tgts.find(*s); + cmMakefile::cmTargetMap::iterator ti = tgts.find(*s); if (ti != tgts.end()) { ti->second.SetInstallPath(args[0]); ti->second.SetRuntimeInstallPath(runtime_dir); diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index ca5f009..7d0e318 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -818,7 +818,7 @@ void cmMakefile::AddCustomCommandToTarget( bool command_expand_lists, ObjectLibraryCommands objLibraryCommands) { // Find the target to which to add the custom command. - cmTargets::iterator ti = this->Targets.find(target); + cmTargetMap::iterator ti = this->Targets.find(target); if (ti == this->Targets.end()) { MessageType messageType = MessageType::AUTHOR_WARNING; @@ -1099,7 +1099,7 @@ void cmMakefile::AddCustomCommandOldStyle( // then add the source to the target to make sure the rule is // included. if (sf && !sf->GetPropertyAsBool("__CMAKE_RULE")) { - cmTargets::iterator ti = this->Targets.find(target); + cmTargetMap::iterator ti = this->Targets.find(target); if (ti != this->Targets.end()) { ti->second.AddSource(sf->GetFullPath()); } else { @@ -2036,7 +2036,7 @@ cmTarget* cmMakefile::AddExecutable(const std::string& exeName, cmTarget* cmMakefile::AddNewTarget(cmStateEnums::TargetType type, const std::string& name) { - cmTargets::iterator it = + cmTargetMap::iterator it = this->Targets .emplace(name, cmTarget(name, type, cmTarget::VisibilityNormal, this)) .first; @@ -3888,7 +3888,7 @@ std::vector<std::string> cmMakefile::GetPropertyKeys() const cmTarget* cmMakefile::FindLocalNonAliasTarget(const std::string& name) const { - cmTargets::iterator i = this->Targets.find(name); + cmTargetMap::iterator i = this->Targets.find(name); if (i != this->Targets.end()) { return &i->second; } diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index be1ac5a..d223347 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -373,14 +373,13 @@ public: return this->ComplainFileRegularExpression.c_str(); } - /** - * Get the list of targets - */ - cmTargets& GetTargets() { return this->Targets; } - /** - * Get the list of targets, const version - */ - const cmTargets& GetTargets() const { return this->Targets; } + // -- List of targets + typedef std::unordered_map<std::string, cmTarget> cmTargetMap; + /** Get the target map */ + cmTargetMap& GetTargets() { return this->Targets; } + /** Get the target map - const version */ + cmTargetMap const& GetTargets() const { return this->Targets; } + const std::vector<cmTarget*>& GetOwnedImportedTargets() const { return this->ImportedTargetsOwned; @@ -896,7 +895,7 @@ protected: mutable std::set<cmListFileContext> CMP0054ReportedIds; // libraries, classes, and executables - mutable cmTargets Targets; + mutable cmTargetMap Targets; std::map<std::string, std::string> AliasTargets; typedef std::vector<cmSourceFile*> SourceFileVec; diff --git a/Source/cmOutputRequiredFilesCommand.cxx b/Source/cmOutputRequiredFilesCommand.cxx index 4ed5581..f3276ec 100644 --- a/Source/cmOutputRequiredFilesCommand.cxx +++ b/Source/cmOutputRequiredFilesCommand.cxx @@ -111,8 +111,7 @@ public: // Now extract any include paths from the targets std::set<std::string> uniqueIncludes; std::vector<std::string> orderedAndUniqueIncludes; - cmTargets& targets = this->Makefile->GetTargets(); - for (auto const& target : targets) { + for (auto const& target : this->Makefile->GetTargets()) { const char* incDirProp = target.second.GetProperty("INCLUDE_DIRECTORIES"); if (!incDirProp) { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 0ac5ca7..fdcca47 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -9,7 +9,6 @@ #include <memory> // IWYU pragma: keep #include <set> #include <string> -#include <unordered_map> #include <utility> #include <vector> @@ -260,6 +259,4 @@ private: std::unique_ptr<cmTargetInternals> impl; }; -typedef std::unordered_map<std::string, cmTarget> cmTargets; - #endif |