summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/cmAddLibraryCommand.cxx14
-rw-r--r--Source/cmAddLibraryCommand.h10
-rw-r--r--Source/cmMakefile.cxx23
-rw-r--r--Source/cmMakefile.h19
-rw-r--r--Source/cmTarget.cxx23
-rw-r--r--Tests/Dependency/CMakeLists.txt2
6 files changed, 62 insertions, 29 deletions
diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx
index a066585..13957b0 100644
--- a/Source/cmAddLibraryCommand.cxx
+++ b/Source/cmAddLibraryCommand.cxx
@@ -33,7 +33,7 @@ bool cmAddLibraryCommand::InitialPass(std::vector<std::string> const& argsIn)
std::vector<std::string>::const_iterator s = args.begin();
- std::string libname = *s;
+ m_LibName = *s;
++s;
@@ -67,8 +67,18 @@ bool cmAddLibraryCommand::InitialPass(std::vector<std::string> const& argsIn)
++s;
}
- m_Makefile->AddLibrary(libname.c_str(), shared, srclists);
+ m_Makefile->AddLibrary(m_LibName.c_str(), shared, srclists);
return true;
}
+void cmAddLibraryCommand::FinalPass()
+{
+ const cmTarget::LinkLibraries& libs = m_Makefile->GetLinkLibraries();
+
+ for( cmTarget::LinkLibraries::const_iterator i = libs.begin();
+ i != libs.end(); ++i )
+ {
+ m_Makefile->AddDependencyToCache( m_LibName.c_str(), i->first );
+ }
+}
diff --git a/Source/cmAddLibraryCommand.h b/Source/cmAddLibraryCommand.h
index e13870e..cb41ccc 100644
--- a/Source/cmAddLibraryCommand.h
+++ b/Source/cmAddLibraryCommand.h
@@ -44,6 +44,13 @@ public:
virtual bool InitialPass(std::vector<std::string> const& args);
/**
+ * This is called at the end after all the information specified by
+ * the command is accumulated. This is where we add in the
+ * dependencies that were globally specified.
+ */
+ virtual void FinalPass();
+
+ /**
* The name of the command as specified in CMakeList.txt.
*/
virtual const char* GetName() { return "ADD_LIBRARY";}
@@ -72,6 +79,9 @@ public:
}
cmTypeMacro(cmAddLibraryCommand, cmCommand);
+
+private:
+ std::string m_LibName;
};
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 091bbb4..9280cf2 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -1362,3 +1362,26 @@ void cmMakefile::EnableLanguage(const char* lang)
{
m_MakefileGenerator->EnableLanguage(lang);
}
+
+
+void cmMakefile::AddDependencyToCache( std::string target, const std::string& lib )
+{
+ // Add the explicit dependency information for this target. This is
+ // simply a set of libraries separated by ";". There should always
+ // be a trailing ";". These library names are not canonical, in that
+ // they may be "-framework x", "-ly", "/path/libz.a", etc.
+ target += "_LIB_DEPENDS";
+ std::string dependencies;
+ const char* old_val = GetDefinition( target.c_str() );
+ if( old_val )
+ {
+ dependencies += old_val;
+ }
+ if( dependencies.find( lib ) == std::string::npos )
+ {
+ dependencies += lib;
+ dependencies += ";";
+ }
+ AddCacheDefinition( target.c_str(), dependencies.c_str(),
+ "Dependencies for the target", cmCacheManager::INTERNAL );
+}
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index d6db91c..742e622 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -155,13 +155,13 @@ public:
const std::vector<std::string> &depends,
const std::vector<std::string> &outputs);
- /**
- * Get a list of link libraries in the build.
- */
- cmTarget::LinkLibraries& GetLinkLibraries()
- {
- return m_LinkLibraries;
- }
+// /**
+// * Get a list of link libraries in the build.
+// */
+// cmTarget::LinkLibraries& GetLinkLibraries()
+// {
+// return m_LinkLibraries;
+// }
/**
* Get a list of link libraries in the build.
@@ -519,6 +519,11 @@ public:
///! Enable support for the named language, if null then all languages are enabled.
void EnableLanguage(const char* );
+
+ /**
+ * Adds the specified library to the explicit dependency list of target.
+ */
+ void AddDependencyToCache( std::string target, const std::string& lib );
protected:
std::string m_Prefix;
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 8410f0e..2896f46 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -90,25 +90,7 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf,
{
m_LinkLibraries.push_back( std::pair<std::string, cmTarget::LinkLibraryType>(lib,llt) );
- // Add the explicit dependency information for this target. This is
- // simply a set of libraries separated by ";". There should always
- // be a trailing ";". These library names are not canonical, in that
- // they may be "-framework x", "-ly", "/path/libz.a", etc.
- std::string cache_name( target );
- cache_name += "_LIB_DEPENDS";
- std::string dependencies;
- const char* old_val = mf.GetDefinition( cache_name.c_str() );
- if( old_val )
- {
- dependencies += old_val;
- }
- if( dependencies.find( lib ) == std::string::npos )
- {
- dependencies += lib;
- dependencies += ";";
- }
- mf.AddCacheDefinition( cache_name.c_str(), dependencies.c_str(),
- "Dependencies for the target", cmCacheManager::INTERNAL );
+ mf.AddDependencyToCache( target, lib );
}
bool cmTarget::HasCxx() const
@@ -125,6 +107,9 @@ bool cmTarget::HasCxx() const
}
+
+
+
void
cmTarget::AnalyzeLibDependencies( const cmMakefile& mf )
{
diff --git a/Tests/Dependency/CMakeLists.txt b/Tests/Dependency/CMakeLists.txt
index 508fe01..3f2bee8 100644
--- a/Tests/Dependency/CMakeLists.txt
+++ b/Tests/Dependency/CMakeLists.txt
@@ -28,7 +28,7 @@ SET( CMAKE_ANALYZE_LIB_DEPENDS "ON" )
# One:
# Two: Three
# Three: One Four
-# Four: One Two A
+# Four: One Two NoDepA
# Five: Two
# SixA: Two Five
# SixB: Four Five