summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2016-04-01 15:47:03 -0400
committerBrad King <brad.king@kitware.com>2016-04-01 15:47:03 -0400
commit58a57105d04564a954256f8441809a4e33a3cb67 (patch)
tree832679b7507ead7bc5a4ae26e68b5e0eb0da0894
parent8f8a0bfbf5a0029430c98feeadc25ab973ff5e38 (diff)
parent0e44f4894f23d5eccd8d360f3420c832f9433a20 (diff)
downloadcmake-58a57105d04564a954256f8441809a4e33a3cb67.tar.gz
Merge branch 'fix-target-alias-in-subdir' into release
-rw-r--r--Source/cmFLTKWrapUICommand.cxx2
-rw-r--r--Source/cmInstallCommand.cxx2
-rw-r--r--Source/cmInstallTargetGenerator.cxx2
-rw-r--r--Source/cmLocalGenerator.cxx15
-rw-r--r--Source/cmLocalGenerator.h3
-rw-r--r--Source/cmMakefile.cxx16
-rw-r--r--Source/cmMakefile.h3
-rw-r--r--Tests/AliasTarget/subdir/CMakeLists.txt5
8 files changed, 15 insertions, 33 deletions
diff --git a/Source/cmFLTKWrapUICommand.cxx b/Source/cmFLTKWrapUICommand.cxx
index d17d6646f1..c64e813158 100644
--- a/Source/cmFLTKWrapUICommand.cxx
+++ b/Source/cmFLTKWrapUICommand.cxx
@@ -117,7 +117,7 @@ void cmFLTKWrapUICommand::FinalPass()
// people should add the srcs to the target themselves, but the old command
// didn't support that, so check and see if they added the files in and if
// they didn;t then print a warning and add then anyhow
- cmTarget* target = this->Makefile->FindTarget(this->Target);
+ cmTarget* target = this->Makefile->FindLocalNonAliasTarget(this->Target);
if(!target)
{
std::string msg =
diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx
index 2d78a4101f..7e72a8a990 100644
--- a/Source/cmInstallCommand.cxx
+++ b/Source/cmInstallCommand.cxx
@@ -381,7 +381,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
return false;
}
// Lookup this target in the current directory.
- if(cmTarget* target=this->Makefile->FindTarget(*targetIt))
+ if(cmTarget* target=this->Makefile->FindLocalNonAliasTarget(*targetIt))
{
// Found the target. Check its type.
if(target->GetType() != cmState::EXECUTABLE &&
diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx
index 5e88fa2c74..b93fb8d618 100644
--- a/Source/cmInstallTargetGenerator.cxx
+++ b/Source/cmInstallTargetGenerator.cxx
@@ -446,7 +446,7 @@ cmInstallTargetGenerator::GetInstallFilename(cmGeneratorTarget const* target,
void cmInstallTargetGenerator::Compute(cmLocalGenerator* lg)
{
- this->Target = lg->FindGeneratorTarget(this->TargetName);
+ this->Target = lg->FindLocalNonAliasGeneratorTarget(this->TargetName);
}
//----------------------------------------------------------------------------
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 912be0c0f0..586e4c69b3 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -485,19 +485,9 @@ private:
std::string Name;
};
-cmGeneratorTarget* cmLocalGenerator::FindGeneratorTarget(
+cmGeneratorTarget* cmLocalGenerator::FindLocalNonAliasGeneratorTarget(
const std::string& name) const
{
- std::map<std::string, std::string>::const_iterator i =
- this->AliasTargets.find(name);
- if (i != this->AliasTargets.end())
- {
- std::vector<cmGeneratorTarget*>::const_iterator ai =
- std::find_if(this->GeneratorTargets.begin(),
- this->GeneratorTargets.end(),
- NamedGeneratorTargetFinder(i->second));
- return *ai;
- }
std::vector<cmGeneratorTarget*>::const_iterator ti =
std::find_if(this->GeneratorTargets.begin(),
this->GeneratorTargets.end(),
@@ -506,7 +496,6 @@ cmGeneratorTarget* cmLocalGenerator::FindGeneratorTarget(
{
return *ti;
}
-
return 0;
}
@@ -1839,7 +1828,7 @@ cmLocalGenerator::FindGeneratorTargetToUse(const std::string& name) const
return *imported;
}
- if(cmGeneratorTarget* t = this->FindGeneratorTarget(name))
+ if(cmGeneratorTarget* t = this->FindLocalNonAliasGeneratorTarget(name))
{
return t;
}
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index 68e7667410..b673a85cc0 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -129,7 +129,8 @@ public:
void AddImportedGeneratorTarget(cmGeneratorTarget* gt);
void AddOwnedImportedGeneratorTarget(cmGeneratorTarget* gt);
- cmGeneratorTarget* FindGeneratorTarget(const std::string& name) const;
+ cmGeneratorTarget*
+ FindLocalNonAliasGeneratorTarget(const std::string& name) const;
cmGeneratorTarget* FindGeneratorTargetToUse(const std::string& name) const;
/**
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 600c985f05..df687d03e4 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -4058,25 +4058,13 @@ std::vector<std::string> cmMakefile::GetPropertyKeys() const
return this->StateSnapshot.GetDirectory().GetPropertyKeys();
}
-cmTarget* cmMakefile::FindTarget(const std::string& name,
- bool excludeAliases) const
+cmTarget* cmMakefile::FindLocalNonAliasTarget(const std::string& name) const
{
- if (!excludeAliases)
- {
- std::map<std::string, std::string>::const_iterator i =
- this->AliasTargets.find(name);
- if (i != this->AliasTargets.end())
- {
- cmTargets::iterator ai = this->Targets.find(i->second);
- return &ai->second;
- }
- }
cmTargets::iterator i = this->Targets.find( name );
if ( i != this->Targets.end() )
{
return &i->second;
}
-
return 0;
}
@@ -4247,7 +4235,7 @@ cmTarget* cmMakefile::FindTargetToUse(const std::string& name,
}
// Look for a target built in this directory.
- if(cmTarget* t = this->FindTarget(name, excludeAliases))
+ if(cmTarget* t = this->FindLocalNonAliasTarget(name))
{
return t;
}
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 362ea75fb5..45f2efb92e 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -388,8 +388,7 @@ public:
}
std::vector<cmTarget*> GetImportedTargets() const;
- cmTarget* FindTarget(const std::string& name,
- bool excludeAliases = false) const;
+ cmTarget* FindLocalNonAliasTarget(const std::string& name) const;
/** Find a target to use in place of the given name. The target
returned may be imported or built within the project. */
diff --git a/Tests/AliasTarget/subdir/CMakeLists.txt b/Tests/AliasTarget/subdir/CMakeLists.txt
index 8c84aea3c2..05a7d86f01 100644
--- a/Tests/AliasTarget/subdir/CMakeLists.txt
+++ b/Tests/AliasTarget/subdir/CMakeLists.txt
@@ -1,3 +1,8 @@
add_library(tgt STATIC empty.cpp)
add_library(Sub::tgt ALIAS tgt)
+
+# foo comes from the top-level CMakeLists.txt
+add_library(Top::foo ALIAS foo)
+get_target_property(some_prop Top::foo SOME_PROP)
+target_link_libraries(tgt Top::foo)