From 0621362668af7b5ec73689c75f6c9318425500f9 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 13 Dec 2010 11:26:53 -0500 Subject: Fix dependency tracing of INSTALL and PACKAGE (#11598) Commit e01cce28 (Allow add_dependencies() on imported targets, 2010-11-19) started using cmMakefile::FindTargetToUse to follow dependencies, including those of GLOBAL_TARGETs like INSTALL and PACKAGE. Since global targets exist in every directory, dependencies between them must be traced within each directory too. Teach FindTargetToUse to check the current directory before checking globally. For global targets this will find the local copy. For for normal targets this will be a no-op because they are globally unique. --- Source/cmMakefile.cxx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 56e0ed9..9983e5d 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -3590,6 +3590,12 @@ cmTarget* cmMakefile::FindTargetToUse(const char* name) return imported->second; } + // Look for a target built in this directory. + if(cmTarget* t = this->FindTarget(name)) + { + return t; + } + // Look for a target built in this project. return this->LocalGenerator->GetGlobalGenerator()->FindTarget(0, name); } -- cgit v0.12 From 8e82773eb4e2bb8d135479410393532021d3b85b Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 13 Dec 2010 11:23:38 -0500 Subject: Remove unused GLOBAL_TARGET generation code Remove a boolean parameter of cmGlobalGenerator::CreateGlobalTarget that is never set to true anymore. Remove global target "consolidation" loop because no global targets exist before it runs anymore. --- Source/cmGlobalGenerator.cxx | 22 ++-------------------- Source/cmGlobalGenerator.h | 3 +-- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 15abd02..ea091f9 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -814,24 +814,11 @@ void cmGlobalGenerator::Generate() // For each existing cmLocalGenerator unsigned int i; - // Consolidate global targets + // Put a copy of each global target in every directory. cmTargets globalTargets; this->CreateDefaultGlobalTargets(&globalTargets); for (i = 0; i < this->LocalGenerators.size(); ++i) { - cmTargets* targets = - &(this->LocalGenerators[i]->GetMakefile()->GetTargets()); - cmTargets::iterator tarIt; - for ( tarIt = targets->begin(); tarIt != targets->end(); ++ tarIt ) - { - if ( tarIt->second.GetType() == cmTarget::GLOBAL_TARGET ) - { - globalTargets[tarIt->first] = tarIt->second; - } - } - } - for (i = 0; i < this->LocalGenerators.size(); ++i) - { cmMakefile* mf = this->LocalGenerators[i]->GetMakefile(); cmTargets* targets = &(mf->GetTargets()); cmTargets::iterator tit; @@ -1881,8 +1868,7 @@ cmTarget cmGlobalGenerator::CreateGlobalTarget( const char* name, const char* message, const cmCustomCommandLines* commandLines, std::vector depends, - const char* workingDirectory, - bool depends_on_all /* = false */) + const char* workingDirectory) { // Package cmTarget target; @@ -1897,10 +1883,6 @@ cmTarget cmGlobalGenerator::CreateGlobalTarget( workingDirectory); target.GetPostBuildCommands().push_back(cc); target.SetProperty("EchoString", message); - if ( depends_on_all ) - { - target.AddUtility("all"); - } std::vector::iterator dit; for ( dit = depends.begin(); dit != depends.end(); ++ dit ) { diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 7e43124..6a1aa53 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -291,8 +291,7 @@ protected: void CreateDefaultGlobalTargets(cmTargets* targets); cmTarget CreateGlobalTarget(const char* name, const char* message, const cmCustomCommandLines* commandLines, - std::vector depends, const char* workingDir, - bool depends_on_all = false); + std::vector depends, const char* workingDir); bool NeedSymbolicMark; bool UseLinkScript; -- cgit v0.12