From 7b4b61a4d38e4c7fe3fe992a6263d8d1f0785858 Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Thu, 23 May 2019 12:52:36 +0200 Subject: 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`. --- Source/cmExportLibraryDependenciesCommand.cxx | 3 +-- Source/cmInstallTargetsCommand.cxx | 4 ++-- Source/cmMakefile.cxx | 8 ++++---- Source/cmMakefile.h | 17 ++++++++--------- Source/cmOutputRequiredFilesCommand.cxx | 3 +-- 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 libDepsNew; std::map 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 const& args, // Enable the install target. this->Makefile->GetGlobalGenerator()->EnableInstallTarget(); - cmTargets& tgts = this->Makefile->GetTargets(); + cmMakefile::cmTargetMap& tgts = this->Makefile->GetTargets(); std::vector::const_iterator s = args.begin(); ++s; std::string runtime_dir = "/bin"; @@ -38,7 +38,7 @@ bool cmInstallTargetsCommand::InitialPass(std::vector 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 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 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& GetOwnedImportedTargets() const { return this->ImportedTargetsOwned; @@ -896,7 +895,7 @@ protected: mutable std::set CMP0054ReportedIds; // libraries, classes, and executables - mutable cmTargets Targets; + mutable cmTargetMap Targets; std::map AliasTargets; typedef std::vector 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 uniqueIncludes; std::vector 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 // IWYU pragma: keep #include #include -#include #include #include @@ -260,6 +259,4 @@ private: std::unique_ptr impl; }; -typedef std::unordered_map cmTargets; - #endif -- cgit v0.12