summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBill Hoffman <bill.hoffman@kitware.com>2002-05-02 17:17:10 (GMT)
committerBill Hoffman <bill.hoffman@kitware.com>2002-05-02 17:17:10 (GMT)
commit27fe57b716555ffa31b16e98841c7f1a82228740 (patch)
tree361f44d30ef7bdba9c37b389824ac9670801177e /Source
parentb5b46599feb33d7f873faca6215f1717ddd209e6 (diff)
downloadCMake-27fe57b716555ffa31b16e98841c7f1a82228740.zip
CMake-27fe57b716555ffa31b16e98841c7f1a82228740.tar.gz
CMake-27fe57b716555ffa31b16e98841c7f1a82228740.tar.bz2
ENH: change LINK_LIBRARY to add to targets
Diffstat (limited to 'Source')
-rw-r--r--Source/cmAddLibraryCommand.cxx9
-rw-r--r--Source/cmAddLibraryCommand.h7
-rw-r--r--Source/cmMakefile.cxx48
-rw-r--r--Source/cmMakefile.h17
-rw-r--r--Source/cmTarget.cxx12
-rw-r--r--Source/cmTarget.h11
-rw-r--r--Source/cmTargetLinkLibrariesCommand.cxx4
-rw-r--r--Source/cmUnixMakefileGenerator.cxx16
8 files changed, 49 insertions, 75 deletions
diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx
index 13957b0..baecbe3 100644
--- a/Source/cmAddLibraryCommand.cxx
+++ b/Source/cmAddLibraryCommand.cxx
@@ -72,13 +72,4 @@ bool cmAddLibraryCommand::InitialPass(std::vector<std::string> const& argsIn)
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 cb41ccc..9f01004 100644
--- a/Source/cmAddLibraryCommand.h
+++ b/Source/cmAddLibraryCommand.h
@@ -44,13 +44,6 @@ 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";}
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 9280cf2..4c31efa 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -428,8 +428,6 @@ void cmMakefile::GenerateMakefile()
l != m_Targets.end(); l++)
{
l->second.GenerateSourceFilesFromSourceLists(*this);
- l->second.MergeLibraries(m_LinkLibraries);
- l->second.MergeDirectories(m_LinkDirectories);
l->second.AnalyzeLibDependencies(*this);
}
// now do the generation
@@ -520,10 +518,11 @@ void cmMakefile::AddLinkLibrary(const char* lib, cmTarget::LinkLibraryType llt)
void cmMakefile::AddLinkLibraryForTarget(const char *target,
const char* lib,
cmTarget::LinkLibraryType llt)
-{
- if (m_Targets.find(target) != m_Targets.end())
+{
+ cmTargets::iterator i = m_Targets.find(target);
+ if ( i != m_Targets.end())
{
- m_Targets[target].AddLinkLibrary( *this, target, lib, llt );
+ i->second.AddLinkLibrary( *this, target, lib, llt );
}
else
{
@@ -531,6 +530,21 @@ void cmMakefile::AddLinkLibraryForTarget(const char *target,
}
}
+void cmMakefile::AddLinkDirectoryForTarget(const char *target,
+ const char* d)
+{
+ cmTargets::iterator i = m_Targets.find(target);
+ if ( i != m_Targets.end())
+ {
+ i->second.AddLinkDirectory( d );
+ }
+ else
+ {
+ cmSystemTools::Error("Attempt to add link directories to non-existant target: ",
+ target, " for directory ", d);
+ }
+}
+
void cmMakefile::AddLinkLibrary(const char* lib)
{
this->AddLinkLibrary(lib,cmTarget::GENERAL);
@@ -654,7 +668,20 @@ void cmMakefile::AddLibrary(const char* lname, int shared,
target.SetInAll(true);
target.GetSourceLists() = srcs;
+ std::vector<std::string>::iterator j;
+ for(j = m_LinkDirectories.begin();
+ j != m_LinkDirectories.end(); ++j)
+ {
+ target.AddLinkDirectory(j->c_str());
+ }
m_Targets.insert(cmTargets::value_type(lname,target));
+ cmTarget::LinkLibraries::iterator i;
+ for(i = m_LinkLibraries.begin(); i != m_LinkLibraries.end(); ++i)
+ {
+ this->AddLinkLibraryForTarget(lname, i->first.c_str(), i->second);
+ }
+
+
// Add an entry into the cache
cmCacheManager::GetInstance()->
@@ -727,7 +754,18 @@ void cmMakefile::AddExecutable(const char *exeName,
}
target.SetInAll(true);
target.GetSourceLists() = srcs;
+ std::vector<std::string>::iterator j;
+ for(j = m_LinkDirectories.begin();
+ j != m_LinkDirectories.end(); ++j)
+ {
+ target.AddLinkDirectory(j->c_str());
+ }
m_Targets.insert(cmTargets::value_type(exeName,target));
+ cmTarget::LinkLibraries::iterator i;
+ for(i = m_LinkLibraries.begin(); i != m_LinkLibraries.end(); ++i)
+ {
+ this->AddLinkLibraryForTarget(exeName, i->first.c_str(), i->second);
+ }
// Add an entry into the cache
cmCacheManager::GetInstance()->
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 742e622..1914dc0 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -155,22 +155,6 @@ 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.
- */
- const cmTarget::LinkLibraries& GetLinkLibraries() const
- {
- return m_LinkLibraries;
- }
-
/**
* Add a link library to the build.
*/
@@ -178,6 +162,7 @@ public:
void AddLinkLibrary(const char*, cmTarget::LinkLibraryType type);
void AddLinkLibraryForTarget(const char *tgt, const char*,
cmTarget::LinkLibraryType type);
+ void AddLinkDirectoryForTarget(const char *tgt, const char* d);
/**
* Add a link directory to the build.
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 2c27c9c..8b12ab0 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -67,16 +67,6 @@ void cmTarget::GenerateSourceFilesFromSourceLists( cmMakefile &mf)
}
}
-void cmTarget::MergeLibraries(const LinkLibraries &ll)
-{
- m_LinkLibraries.insert( m_LinkLibraries.end(), ll.begin(), ll.end() );
-}
-
-void cmTarget::MergeDirectories(const std::vector<std::string> &ld)
-{
- m_LinkDirectories.insert( m_LinkDirectories.end(), ld.begin(), ld.end() );
-}
-
void cmTarget::AddLinkLibrary(const std::string& lib,
LinkLibraryType llt)
@@ -276,7 +266,9 @@ void cmTarget::Emit( const std::string& lib,
{
// It's already been emitted
if( emitted.find(lib) != emitted.end() )
+ {
return;
+ }
// If this library hasn't been visited before, then emit all its
// dependencies before emitting the library itself. If it has been
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index 6abdab2..124c04c 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -81,6 +81,7 @@ public:
const LinkLibraries &GetLinkLibraries() const {return m_LinkLibraries;}
const std::vector<std::string>& GetLinkDirectories() const {return m_LinkDirectories;}
+ void AddLinkDirectory(const char* d) { m_LinkDirectories.push_back(d);}
/**
* Set the path where this target should be installed. This is relative to
@@ -97,16 +98,6 @@ public:
LinkLibraryType llt);
/**
- * Merge Link Libraries into this targets current list
- */
- void MergeLibraries(const LinkLibraries &ll);
-
- /**
- * Merge Link Directories into this targets current list
- */
- void MergeDirectories(const std::vector<std::string> &ld);
-
- /**
* Generate the SourceFilesList from the SourceLists. This should only be
* done once to be safe.
*/
diff --git a/Source/cmTargetLinkLibrariesCommand.cxx b/Source/cmTargetLinkLibrariesCommand.cxx
index 34c57a3..143cf86 100644
--- a/Source/cmTargetLinkLibrariesCommand.cxx
+++ b/Source/cmTargetLinkLibrariesCommand.cxx
@@ -57,12 +57,12 @@ bool cmTargetLinkLibrariesCommand::InitialPass(std::vector<std::string> const& a
const char* dir = m_Makefile->GetDefinition(i->c_str());
if( dir )
{
- m_Makefile->AddLinkDirectory( dir );
+ m_Makefile->AddLinkDirectoryForTarget(args[0].c_str(), dir );
}
}
else
{
- m_Makefile->AddLinkDirectory( ldir );
+ m_Makefile->AddLinkDirectoryForTarget(args[0].c_str(), ldir );
}
}
return true;
diff --git a/Source/cmUnixMakefileGenerator.cxx b/Source/cmUnixMakefileGenerator.cxx
index 9a31a20..5609bda 100644
--- a/Source/cmUnixMakefileGenerator.cxx
+++ b/Source/cmUnixMakefileGenerator.cxx
@@ -890,22 +890,6 @@ void cmUnixMakefileGenerator::OutputDependLibs(std::ostream& fout)
// A library should not depend on itself!
emitted.insert(l->first);
- // First look at all makefile level link libraries.
- const cmTarget::LinkLibraries& libs = m_Makefile->GetLinkLibraries();
- for(cmTarget::LinkLibraries::const_iterator lib = libs.begin();
- lib != libs.end(); ++lib)
- {
- // Record that this library was used.
- used.insert(lib->first);
-
- // Don't emit the same library twice for this target.
- if(emitted.insert(lib->first).second)
- {
- // Output this dependency.
- this->OutputLibDepend(fout, lib->first.c_str());
- }
- }
-
// Now, look at all link libraries specific to this target.
const cmTarget::LinkLibraries& tlibs = l->second.GetLinkLibraries();
for(cmTarget::LinkLibraries::const_iterator lib = tlibs.begin();