[Cmake-commits] CMake branch, next, updated. v2.8.10.1-1019-g0989a82
Stephen Kelly
steveire at gmail.com
Sat Nov 24 09:57:42 EST 2012
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".
The branch, next has been updated
via 0989a82a7ce33ca2e57f6c862aa473d3613d1611 (commit)
via 955d111c30cc8b171d5b616961ef8e6ca0a48da1 (commit)
via 57627ca374f1de0fe5ff033b0b5979f0fde97fc0 (commit)
via c8ac6faf1369830a4ec91d4799a20dc70d7df9ab (commit)
from 7ef33783f7008ee963f91f9a33f32e85c5cdcd9f (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0989a82a7ce33ca2e57f6c862aa473d3613d1611
commit 0989a82a7ce33ca2e57f6c862aa473d3613d1611
Merge: 7ef3378 955d111
Author: Stephen Kelly <steveire at gmail.com>
AuthorDate: Sat Nov 24 09:57:38 2012 -0500
Commit: CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Sat Nov 24 09:57:38 2012 -0500
Merge topic 'link-libraries-generator-expression' into next
955d111 Make targets depend on the (config-specific) union of dependencies.
57627ca Generate the frameworks linked by a target lazily.
c8ac6fa Add cmTarget::GetDirectLinkDependencies.
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=955d111c30cc8b171d5b616961ef8e6ca0a48da1
commit 955d111c30cc8b171d5b616961ef8e6ca0a48da1
Author: Stephen Kelly <steveire at gmail.com>
AuthorDate: Wed Oct 31 17:09:57 2012 +0100
Commit: Stephen Kelly <steveire at gmail.com>
CommitDate: Sat Nov 24 15:41:10 2012 +0100
Make targets depend on the (config-specific) union of dependencies.
Future CMake features will allow linking to dependencies or not
depending on the config. However, generated buildsystems are not
capable of processing config-specific dependencies, so the targets
depend on the union of dependencies for all configs.
diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx
index ab77c6b..2acbfff 100644
--- a/Source/cmComputeTargetDepends.cxx
+++ b/Source/cmComputeTargetDepends.cxx
@@ -200,20 +200,44 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index)
// Get the depender.
cmTarget* depender = this->Targets[depender_index];
- // Loop over all targets linked directly.
+ // Loop over all targets linked directly in all configs.
+ // We need to make targets depend on the union of all config-specific
+ // dependencies in all targets, because the generated build-systems can't
+ // deal with config-specific dependencies.
{
- cmTarget::LinkLibraryVectorType const& tlibs =
- depender->GetOriginalLinkLibraries();
+ std::vector<std::string> configs;
+ depender->GetMakefile()->GetConfigurations(configs);
std::set<cmStdString> emitted;
+ {
+ std::vector<std::string> tlibs;
+ depender->GetDirectLinkLibraries(0, tlibs);
// A target should not depend on itself.
emitted.insert(depender->GetName());
- for(cmTarget::LinkLibraryVectorType::const_iterator lib = tlibs.begin();
+ for(std::vector<std::string>::const_iterator lib = tlibs.begin();
lib != tlibs.end(); ++lib)
{
// Don't emit the same library twice for this target.
- if(emitted.insert(lib->first).second)
+ if(emitted.insert(*lib).second)
+ {
+ this->AddTargetDepend(depender_index, lib->c_str(), true);
+ }
+ }
+ }
+ for (std::vector<std::string>::const_iterator it = configs.begin();
+ it != configs.end(); ++it)
+ {
+ std::vector<std::string> tlibs;
+ depender->GetDirectLinkLibraries(it->c_str(), tlibs);
+ // A target should not depend on itself.
+ emitted.insert(depender->GetName());
+ for(std::vector<std::string>::const_iterator lib = tlibs.begin();
+ lib != tlibs.end(); ++lib)
{
- this->AddTargetDepend(depender_index, lib->first.c_str(), true);
+ // Don't emit the same library twice for this target.
+ if(emitted.insert(*lib).second)
+ {
+ this->AddTargetDepend(depender_index, lib->c_str(), true);
+ }
}
}
}
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=57627ca374f1de0fe5ff033b0b5979f0fde97fc0
commit 57627ca374f1de0fe5ff033b0b5979f0fde97fc0
Author: Stephen Kelly <steveire at gmail.com>
AuthorDate: Thu Nov 1 10:41:53 2012 +0100
Commit: Stephen Kelly <steveire at gmail.com>
CommitDate: Sat Nov 24 15:41:10 2012 +0100
Generate the frameworks linked by a target lazily.
As this is only needed at generate-time, it can depend on the
config.
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 9bbeeaf..d9b586e 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -1997,7 +1997,8 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
dirs.Add(incpath.c_str());
}
}
- std::vector<std::string>& frameworks = target.GetFrameworks();
+ std::vector<std::string> frameworks;
+ target.GetFrameworks(configName, frameworks);
if(frameworks.size())
{
for(std::vector<std::string>::iterator fmIt = frameworks.begin();
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index 2b89c79..f46edf3 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -1565,7 +1565,8 @@ std::string cmMakefileTargetGenerator::GetFrameworkFlags()
}
std::string flags;
- std::vector<std::string>& frameworks = this->Target->GetFrameworks();
+ std::vector<std::string> frameworks;
+ this->Target->GetFrameworks(config, frameworks);
for(i = frameworks.begin();
i != frameworks.end(); ++i)
{
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index a7c5fcd..c0d2f4f 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -2110,23 +2110,27 @@ bool cmTarget::NameResolvesToFramework(const std::string& libname)
}
//----------------------------------------------------------------------------
-bool cmTarget::AddFramework(const std::string& libname, LinkLibraryType)
+void cmTarget::GetFrameworks(const char *config,
+ std::vector<std::string> &frameworks)
{
- if(this->NameResolvesToFramework(libname.c_str()))
+ std::vector<std::string> llibs;
+ this->GetDirectLinkLibraries(config, llibs);
+ for(std::vector<std::string>::const_iterator li = llibs.begin();
+ li != llibs.end(); ++li)
{
- std::string frameworkDir = libname;
- frameworkDir += "/../";
- frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir.c_str());
- std::vector<std::string>::iterator i =
- std::find(this->Frameworks.begin(),
- this->Frameworks.end(), frameworkDir);
- if(i == this->Frameworks.end())
+ if(this->NameResolvesToFramework(li->c_str()))
{
- this->Frameworks.push_back(frameworkDir);
+ std::string frameworkDir = *li + "/../";
+ frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir.c_str());
+ std::vector<std::string>::iterator i =
+ std::find(frameworks.begin(),
+ frameworks.end(), frameworkDir);
+ if(i == frameworks.end())
+ {
+ frameworks.push_back(frameworkDir);
+ }
}
- return true;
}
- return false;
}
//----------------------------------------------------------------------------
@@ -2194,7 +2198,6 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf,
return;
}
- this->AddFramework(pplib, llt);
cmTarget::LibraryID tmp;
tmp.first = pplib;
tmp.second = llt;
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index c72e4c5..3cd35f4 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -114,7 +114,8 @@ public:
{return this->PostBuildCommands;}
///! Return the list of frameworks being linked to this target
- std::vector<std::string> &GetFrameworks() {return this->Frameworks;}
+ void GetFrameworks(const char *config,
+ std::vector<std::string> &frameworks);
/**
* Get the list of the source files used by this target
@@ -185,7 +186,6 @@ public:
// Check to see if a library is a framework and treat it different on Mac
bool NameResolvesToFramework(const std::string& libname);
- bool AddFramework(const std::string& lib, LinkLibraryType llt);
void AddLinkLibrary(cmMakefile& mf,
const char *target, const char* lib,
LinkLibraryType llt);
@@ -580,7 +580,6 @@ private:
LinkLibraryVectorType LinkLibraries;
LinkLibraryVectorType PrevLinkedLibraries;
bool LinkLibrariesAnalyzed;
- std::vector<std::string> Frameworks;
std::vector<std::string> LinkDirectories;
std::set<cmStdString> LinkDirectoriesEmmitted;
bool HaveInstallRule;
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c8ac6faf1369830a4ec91d4799a20dc70d7df9ab
commit c8ac6faf1369830a4ec91d4799a20dc70d7df9ab
Author: Stephen Kelly <steveire at gmail.com>
AuthorDate: Thu Nov 1 00:29:30 2012 +0100
Commit: Stephen Kelly <steveire at gmail.com>
CommitDate: Sat Nov 24 15:41:10 2012 +0100
Add cmTarget::GetDirectLinkDependencies.
This will be used at generate-time and can use generator expressions.
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 55c47c8..a7c5fcd 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -2130,6 +2130,48 @@ bool cmTarget::AddFramework(const std::string& libname, LinkLibraryType)
}
//----------------------------------------------------------------------------
+void cmTarget::GetDirectLinkLibraries(const char *config,
+ std::vector<std::string> &libs) const
+{
+ const char *prop = const_cast<cmTarget*>(this)
+ ->GetProperty("LINK_LIBRARIES");
+ if (prop)
+ {
+ cmListFileBacktrace lfbt;
+ cmGeneratorExpression ge(lfbt);
+
+ cmGeneratorExpressionDAGChecker dagChecker(lfbt,
+ this->GetName(),
+ "LINK_LIBRARIES", 0, 0);
+ cmSystemTools::ExpandListArgument(ge.Parse(prop)->Evaluate(this->Makefile,
+ config,
+ false,
+ const_cast<cmTarget*>(this),
+ &dagChecker),
+ libs);
+ }
+}
+
+//----------------------------------------------------------------------------
+static std::string generatorIface(const std::string &value,
+ cmTarget::LinkLibraryType llt)
+{
+ if (llt == cmTarget::DEBUG)
+ {
+ return "$<$<CONFIG:Debug>:"
+ + value
+ + ">";
+ }
+ else if (llt == cmTarget::OPTIMIZED)
+ {
+ return "$<$<NOT:$<CONFIG:Debug>>:"
+ + value
+ + ">";
+ }
+ return value;
+}
+
+//----------------------------------------------------------------------------
void cmTarget::AddLinkLibrary(cmMakefile& mf,
const char *target, const char* lib,
LinkLibraryType llt)
@@ -2139,9 +2181,22 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf,
{
return;
}
- this->AddFramework(lib, llt);
+
+ this->AppendProperty("LINK_LIBRARIES",
+ generatorIface(lib, llt).c_str());
+
+ std::string pplib = cmGeneratorExpression::Preprocess(
+ lib,
+ cmGeneratorExpression::StripAllGeneratorExpressions);
+
+ if (pplib.empty())
+ {
+ return;
+ }
+
+ this->AddFramework(pplib, llt);
cmTarget::LibraryID tmp;
- tmp.first = lib;
+ tmp.first = pplib;
tmp.second = llt;
this->LinkLibraries.push_back( tmp );
this->OriginalLinkLibraries.push_back(tmp);
@@ -2178,7 +2233,7 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf,
break;
}
dependencies += ";";
- dependencies += lib;
+ dependencies += pplib;
dependencies += ";";
mf.AddCacheDefinition( targetEntry.c_str(), dependencies.c_str(),
"Dependencies for the target",
@@ -5014,21 +5069,19 @@ void cmTarget::ComputeLinkImplementation(const char* config,
cmTarget::LinkLibraryType linkType = this->ComputeLinkType(config);
// Collect libraries directly linked in this configuration.
- LinkLibraryVectorType const& llibs = this->GetOriginalLinkLibraries();
- for(cmTarget::LinkLibraryVectorType::const_iterator li = llibs.begin();
+ std::vector<std::string> llibs;
+ this->GetDirectLinkLibraries(config, llibs);
+ for(std::vector<std::string>::const_iterator li = llibs.begin();
li != llibs.end(); ++li)
{
// Skip entries that resolve to the target itself or are empty.
- std::string item = this->CheckCMP0004(li->first);
+ std::string item = this->CheckCMP0004(*li);
if(item == this->GetName() || item.empty())
{
continue;
}
- if(li->second == cmTarget::GENERAL || li->second == linkType)
- {
- // The entry is meant for this configuration.
- impl.Libraries.push_back(item);
- }
+ // The entry is meant for this configuration.
+ impl.Libraries.push_back(item);
}
LinkLibraryVectorType const& oldllibs = this->GetOriginalLinkLibraries();
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index a6090e5..c72e4c5 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -172,6 +172,8 @@ public:
return this->LinkLibraries;}
const LinkLibraryVectorType &GetOriginalLinkLibraries() const
{return this->OriginalLinkLibraries;}
+ void GetDirectLinkLibraries(const char *config,
+ std::vector<std::string> &) const;
/** Compute the link type to use for the given configuration. */
LinkLibraryType ComputeLinkType(const char* config);
diff --git a/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt b/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt
index 92c9338..1e3094c 100644
--- a/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt
+++ b/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt
@@ -37,11 +37,11 @@ target_link_libraries(depB LINK_PRIVATE depA)
add_library(depC SHARED depC.cpp)
generate_export_header(depC)
-target_link_libraries(depC LINK_PUBLIC depA)
+target_link_libraries(depC LINK_PUBLIC $<1:depA>)
assert_property(depA LINK_INTERFACE_LIBRARIES "")
assert_property(depB LINK_INTERFACE_LIBRARIES "")
-assert_property(depC LINK_INTERFACE_LIBRARIES "depA")
+assert_property(depC LINK_INTERFACE_LIBRARIES "$<1:depA>")
add_executable(targetA targetA.cpp)
-----------------------------------------------------------------------
Summary of changes:
Source/cmComputeTargetDepends.cxx | 36 ++++++-
Source/cmGlobalXCodeGenerator.cxx | 3 +-
Source/cmMakefileTargetGenerator.cxx | 3 +-
Source/cmTarget.cxx | 104 +++++++++++++++-----
Source/cmTarget.h | 7 +-
.../target_link_libraries/CMakeLists.txt | 4 +-
6 files changed, 120 insertions(+), 37 deletions(-)
hooks/post-receive
--
CMake
More information about the Cmake-commits
mailing list